MCPcopy Create free account
hub / github.com/dask/dask / test_min_max_empty_chunks

Function test_min_max_empty_chunks

dask/array/tests/test_reductions.py:357–374  ·  view source on GitHub ↗
(dfunc, func)

Source from the content-addressed store, hash-verified

355
356@pytest.mark.parametrize(["dfunc", "func"], [(da.min, np.min), (da.max, np.max)])
357def test_min_max_empty_chunks(dfunc, func):
358 x1 = np.arange(10)
359 a1 = da.from_array(x1, chunks=1)
360 assert_eq(dfunc(a1[a1 < 2]), func(x1[x1 < 2]))
361
362 x2 = np.arange(10)
363 a2 = da.from_array(x2, chunks=((5, 0, 5),))
364 assert_eq(dfunc(a2), func(x2))
365
366 x3 = np.array([[1, 1, 2, 3], [1, 1, 4, 0]])
367 a3 = da.from_array(x3, chunks=1)
368 assert_eq(dfunc(a3[a3 >= 2]), func(x3[x3 >= 2]))
369
370 a4 = da.arange(10)
371 with pytest.raises(
372 ValueError
373 ): # Checking it mimics numpy behavior when all chunks are empty
374 dfunc(a4[a4 < 0]).compute()
375
376
377@pytest.mark.parametrize("func", ["argmax", "nanargmax"])

Callers

nothing calls this directly

Calls 4

assert_eqFunction · 0.90
funcFunction · 0.70
arangeMethod · 0.45
computeMethod · 0.45

Tested by

no test coverage detected