(enc_chunks, region, nd_v_chunks, expected_chunks)
| 96 | ], |
| 97 | ) |
| 98 | def test_grid_rechunk(enc_chunks, region, nd_v_chunks, expected_chunks): |
| 99 | dims = [f"dim_{i}" for i in range(len(region))] |
| 100 | coords = { |
| 101 | dim: list(range(r.start, r.stop)) for dim, r in zip(dims, region, strict=False) |
| 102 | } |
| 103 | shape = tuple(r.stop - r.start for r in region) |
| 104 | arr = xr.DataArray( |
| 105 | np.arange(np.prod(shape)).reshape(shape), |
| 106 | dims=dims, |
| 107 | coords=coords, |
| 108 | ) |
| 109 | arr = arr.chunk(dict(zip(dims, nd_v_chunks, strict=False))) |
| 110 | |
| 111 | result = grid_rechunk( |
| 112 | arr.variable, |
| 113 | enc_chunks=enc_chunks, |
| 114 | region=region, |
| 115 | ) |
| 116 | assert result.chunks == expected_chunks |
nothing calls this directly
no test coverage detected
searching dependent graphs…