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

Method test_unstack_errors

xarray/tests/test_dataset.py:4202–4218  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4200 assert_identical(actual, expected)
4201
4202 def test_unstack_errors(self) -> None:
4203 ds = Dataset({"x": [1, 2, 3]})
4204 with pytest.raises(
4205 ValueError,
4206 match=re.escape("Dimensions ('foo',) not found in data dimensions ('x',)"),
4207 ):
4208 ds.unstack("foo")
4209 with pytest.raises(ValueError, match=r".*do not have exactly one multi-index"):
4210 ds.unstack("x")
4211
4212 ds = Dataset({"da": [1, 2]}, coords={"y": ("x", [1, 1]), "z": ("x", [0, 0])})
4213 ds = ds.set_index(x=("y", "z"))
4214
4215 with pytest.raises(
4216 ValueError, match="Cannot unstack MultiIndex containing duplicates"
4217 ):
4218 ds.unstack("x")
4219
4220 def test_unstack_fill_value(self) -> None:
4221 ds = xr.Dataset(

Callers

nothing calls this directly

Calls 3

unstackMethod · 0.95
set_indexMethod · 0.95
DatasetClass · 0.90

Tested by

no test coverage detected