(dtype, reduction)
| 248 | "reduction", ["sum", "prod", "mean", "var", "std", "min", "max", "any", "all"] |
| 249 | ) |
| 250 | def 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")) |
nothing calls this directly
no test coverage detected