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

Function test_reductions

dask/array/tests/test_masked.py:250–271  ·  view source on GitHub ↗
(dtype, reduction)

Source from the content-addressed store, hash-verified

248 "reduction", ["sum", "prod", "mean", "var", "std", "min", "max", "any", "all"]
249)
250def test_reductions(dtype, reduction):
251 x = (np.random.default_rng(42).random((11, 11)) * 10).astype(dtype)
252 dx = da.from_array(x, chunks=(4, 4))
253 mx = np.ma.masked_greater(x, 5)
254 mdx = da.ma.masked_greater(dx, 5)
255
256 dfunc = getattr(da, reduction)
257 func = getattr(np, reduction)
258
259 assert_eq_ma(dfunc(mdx), func(mx))
260 assert_eq_ma(dfunc(mdx, axis=0), func(mx, axis=0))
261 assert_eq_ma(dfunc(mdx, keepdims=True, split_every=4), func(mx, keepdims=True))
262 assert_eq_ma(dfunc(mdx, axis=0, split_every=2), func(mx, axis=0))
263 assert_eq_ma(
264 dfunc(mdx, axis=0, keepdims=True, split_every=2),
265 func(mx, axis=0, keepdims=True),
266 )
267 assert_eq_ma(dfunc(mdx, axis=1, split_every=2), func(mx, axis=1))
268 assert_eq_ma(
269 dfunc(mdx, axis=1, keepdims=True, split_every=2),
270 func(mx, axis=1, keepdims=True),
271 )
272
273
274@pytest.mark.parametrize("dtype", ("i8", "f8"))

Callers

nothing calls this directly

Calls 4

assert_eq_maFunction · 0.85
funcFunction · 0.70
astypeMethod · 0.45
randomMethod · 0.45

Tested by

no test coverage detected