Skip to content

Commit 51a47f6

Browse files
authored
Add test against graph duplication (#74)
1 parent fc8fe5b commit 51a47f6

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

recursive_diff/tests/test_recursive_diff.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,3 +1478,28 @@ def test_p2p_rechunk():
14781478

14791479
with distributed.Client(n_workers=2, threads_per_worker=1):
14801480
check(a, b, "[data][x=c]: 3 != 4 (abs: 1.0e+00, rel: 3.3e-01)")
1481+
1482+
1483+
@requires_dask
1484+
def test_do_not_duplicate_input_graph():
1485+
"""Test that recursive_diff does not encroach on
1486+
https://github.com/dask/dask/issues/12318
1487+
"""
1488+
import dask.array as da
1489+
1490+
count = []
1491+
1492+
def f(x):
1493+
count.append(x[0].item())
1494+
return x
1495+
1496+
a = xarray.DataArray(da.asarray(["a"]).map_blocks(f), name="x")
1497+
b = xarray.DataArray(da.asarray(["b"]).map_blocks(f), name="x")
1498+
count.clear()
1499+
1500+
check(a, b, "[data][0]: a != b")
1501+
assert sorted(count) == ["a", "b"]
1502+
count.clear()
1503+
1504+
check(a, b, "[data]: 1 differences", brief_dims="all")
1505+
assert sorted(count) == ["a", "b"]

0 commit comments

Comments
 (0)