Skip to content

Commit a4bda14

Browse files
committed
Add test
1 parent 1933e0b commit a4bda14

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

xarray/tests/test_dask.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,3 +1746,20 @@ def test_new_index_var_computes_once():
17461746
data = dask.array.from_array(np.array([100, 200]))
17471747
with raise_if_dask_computes(max_computes=1):
17481748
Dataset(coords={"z": ("z", data)})
1749+
1750+
1751+
def test_minimize_graph_size():
1752+
import cloudpickle
1753+
1754+
# regression test for https://github.com/pydata/xarray/issues/8409
1755+
ds = Dataset(
1756+
{"foo": (("x", "y", "z"), dask.array.ones((120, 120, 120)))},
1757+
coords={"x": np.arange(120), "y": np.arange(120), "z": np.arange(120)},
1758+
).chunk(x=20, y=20, z=1)
1759+
1760+
actual = len(cloudpickle.dumps(ds.map_blocks(lambda x: x)))
1761+
expected = len(cloudpickle.dumps(ds.drop_vars(ds.dims).map_blocks(lambda x: x)))
1762+
1763+
# prior to https://github.com/pydata/xarray/pull/8412
1764+
# actual is ~5x expected
1765+
assert actual < 2 * expected

0 commit comments

Comments
 (0)