| 5111 | ], |
| 5112 | ) |
| 5113 | def test_zarr_irregular_chunks(shape, chunks, expect_rechunk): |
| 5114 | pytest.importorskip("zarr") |
| 5115 | with tmpdir() as d: |
| 5116 | a = da.zeros(shape, chunks=chunks) # ((2, 1, 1, 2), 1)) |
| 5117 | if expect_rechunk: |
| 5118 | with pytest.warns(UserWarning, match="The array uses irregular chunk"): |
| 5119 | store_delayed = a.to_zarr(d, component="test", compute=False) |
| 5120 | else: |
| 5121 | store_delayed = a.to_zarr(d, component="test", compute=False) |
| 5122 | assert ( |
| 5123 | any("rechunk" in key_split(k) for k in dict(store_delayed.dask)) |
| 5124 | is expect_rechunk |
| 5125 | ) |
| 5126 | store_delayed.compute() |
| 5127 | |
| 5128 | |
| 5129 | @pytest.mark.parametrize( |