MCPcopy Index your code
hub / github.com/pydata/xarray / test_concat_compat

Function test_concat_compat

xarray/tests/test_concat.py:125–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

123
124
125def test_concat_compat() -> None:
126 ds1 = Dataset(
127 {
128 "has_x_y": (("y", "x"), [[1, 2]]),
129 "has_x": ("x", [1, 2]),
130 "no_x_y": ("z", [1, 2]),
131 },
132 coords={"x": [0, 1], "y": [0], "z": [-1, -2]},
133 )
134 ds2 = Dataset(
135 {
136 "has_x_y": (("y", "x"), [[3, 4]]),
137 "has_x": ("x", [1, 2]),
138 "no_x_y": (("q", "z"), [[1, 2]]),
139 },
140 coords={"x": [0, 1], "y": [1], "z": [-1, -2], "q": [0]},
141 )
142
143 result = concat([ds1, ds2], dim="y", data_vars="minimal", compat="broadcast_equals")
144 assert_equal(ds2.no_x_y, result.no_x_y.transpose())
145
146 for var in ["has_x", "no_x_y"]:
147 assert "y" not in result[var].dims and "y" not in result[var].coords
148 with pytest.raises(ValueError, match=r"'q' not present in all datasets"):
149 concat([ds1, ds2], dim="q", data_vars="all", join="outer")
150 with pytest.raises(ValueError, match=r"'q' not present in all datasets"):
151 concat([ds2, ds1], dim="q", data_vars="all", join="outer")
152
153
154def test_concat_missing_var() -> None:

Callers

nothing calls this directly

Calls 4

DatasetClass · 0.90
concatFunction · 0.90
assert_equalFunction · 0.90
transposeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…