MCPcopy
hub / github.com/pydata/xarray / test_lazy_array_equiv_variables

Function test_lazy_array_equiv_variables

xarray/tests/test_dask.py:1693–1715  ·  view source on GitHub ↗
(compat)

Source from the content-addressed store, hash-verified

1691 "compat", ["broadcast_equals", "equals", "identical", "no_conflicts"]
1692)
1693def test_lazy_array_equiv_variables(compat):
1694 var1 = xr.Variable(("y", "x"), da.zeros((10, 10), chunks=2))
1695 var2 = xr.Variable(("y", "x"), da.zeros((10, 10), chunks=2))
1696 var3 = xr.Variable(("y", "x"), da.zeros((20, 10), chunks=2))
1697
1698 with raise_if_dask_computes():
1699 assert getattr(var1, compat)(var2, equiv=lazy_array_equiv)
1700 # values are actually equal, but we don't know that till we compute, return None
1701 with raise_if_dask_computes():
1702 assert getattr(var1, compat)(var2 / 2, equiv=lazy_array_equiv) is None
1703
1704 # shapes are not equal, return False without computes
1705 with raise_if_dask_computes():
1706 assert getattr(var1, compat)(var3, equiv=lazy_array_equiv) is False
1707
1708 # if one or both arrays are numpy, return None
1709 assert getattr(var1, compat)(var2.compute(), equiv=lazy_array_equiv) is None
1710 assert (
1711 getattr(var1.compute(), compat)(var2.compute(), equiv=lazy_array_equiv) is None
1712 )
1713
1714 with raise_if_dask_computes():
1715 assert getattr(var1, compat)(var2.transpose("y", "x"))
1716
1717
1718@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 3

computeMethod · 0.95
transposeMethod · 0.95
raise_if_dask_computesFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…