| 932 | "axes", list(permutations((0, 1, 2), 2)) + list(permutations((0, 1, 2))) |
| 933 | ) |
| 934 | def test_chunk_structure_independence(axes, split_every, chunks): |
| 935 | # Reducing an array should not depend on its chunk-structure!!! |
| 936 | # See Issue #8541: https://github.com/dask/dask/issues/8541 |
| 937 | shape = tuple(np.sum(s) for s in chunks) |
| 938 | np_array = np.arange(np.prod(shape)).reshape(*shape) |
| 939 | x = da.from_array(np_array, chunks=chunks) |
| 940 | reduced_x = da.reduction( |
| 941 | x, |
| 942 | lambda x, axis, keepdims: x, |
| 943 | lambda x, axis, keepdims: x, |
| 944 | keepdims=True, |
| 945 | axis=axes, |
| 946 | split_every=split_every, |
| 947 | dtype=x.dtype, |
| 948 | meta=x._meta, |
| 949 | ) |
| 950 | assert_eq(reduced_x, np_array, check_chunks=False, check_shape=False) |
| 951 | |
| 952 | |
| 953 | def test_weighted_reduction(): |