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

Function test_assert_allclose_equal_transpose

xarray/tests/test_assertions.py:90–103  ·  view source on GitHub ↗

Transposed DataArray raises assertion unless check_dim_order=False.

(func)

Source from the content-addressed store, hash-verified

88
89@pytest.mark.parametrize("func", ["assert_equal", "assert_allclose"])
90def test_assert_allclose_equal_transpose(func) -> None:
91 """Transposed DataArray raises assertion unless check_dim_order=False."""
92 obj1 = xr.DataArray([[0, 1, 2], [2, 3, 4]], dims=["a", "b"])
93 obj2 = xr.DataArray([[0, 2], [1, 3], [2, 4]], dims=["b", "a"])
94 with pytest.raises(AssertionError):
95 getattr(xr.testing, func)(obj1, obj2)
96 getattr(xr.testing, func)(obj1, obj2, check_dim_order=False)
97 ds1 = obj1.to_dataset(name="varname")
98 ds1["var2"] = obj1
99 ds2 = obj1.to_dataset(name="varname")
100 ds2["var2"] = obj1.transpose()
101 with pytest.raises(AssertionError):
102 getattr(xr.testing, func)(ds1, ds2)
103 getattr(xr.testing, func)(ds1, ds2, check_dim_order=False)
104
105
106def test_assert_equal_transpose_datatree() -> None:

Callers

nothing calls this directly

Calls 2

to_datasetMethod · 0.95
transposeMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…