|
2 | 2 |
|
3 | 3 | import cubed |
4 | 4 | import cubed as xp |
| 5 | +from cubed.core.ops import _store_array |
5 | 6 |
|
6 | 7 |
|
7 | 8 | @pytest.mark.parametrize( |
@@ -85,3 +86,24 @@ def test_rechunk_era5_chunk_sizes(spec): |
85 | 86 | ((22528, 41, 109), (22528, 10, 30)), |
86 | 87 | ((350640, 10, 30), (350640, 10, 10)), |
87 | 88 | ] |
| 89 | + |
| 90 | + |
| 91 | +def test_rechunk_and_store(): |
| 92 | + # from https://github.com/cubed-dev/cubed/issues/859 |
| 93 | + shape = (394488, 778, 706) |
| 94 | + source_chunks = (24, 778, 706) |
| 95 | + target_chunks = (43800, 5, 5) |
| 96 | + spec = cubed.Spec(allowed_mem="5GB") |
| 97 | + |
| 98 | + a = xp.empty(shape, dtype=xp.float32, chunks=source_chunks, spec=spec) |
| 99 | + b = a.rechunk(target_chunks) |
| 100 | + |
| 101 | + num_tasks = b.plan().num_tasks |
| 102 | + |
| 103 | + # simulate what to_zarr or store does |
| 104 | + c = _store_array(b, None) |
| 105 | + |
| 106 | + c.visualize() |
| 107 | + |
| 108 | + # store should not change number of tasks |
| 109 | + assert c.plan().num_tasks == num_tasks |
0 commit comments