(self)
| 4184 | assert list(actual.xindexes) == ["z", "xx", "y"] |
| 4185 | |
| 4186 | def test_unstack(self) -> None: |
| 4187 | index = pd.MultiIndex.from_product([[0, 1], ["a", "b"]], names=["x", "y"]) |
| 4188 | coords = Coordinates.from_pandas_multiindex(index, "z") |
| 4189 | ds = Dataset(data_vars={"b": ("z", [0, 1, 2, 3])}, coords=coords) |
| 4190 | expected = Dataset( |
| 4191 | {"b": (("x", "y"), [[0, 1], [2, 3]]), "x": [0, 1], "y": ["a", "b"]} |
| 4192 | ) |
| 4193 | |
| 4194 | # check attrs propagated |
| 4195 | ds["x"].attrs["foo"] = "bar" |
| 4196 | expected["x"].attrs["foo"] = "bar" |
| 4197 | |
| 4198 | for dim in ["z", ["z"], None]: |
| 4199 | actual = ds.unstack(dim) |
| 4200 | assert_identical(actual, expected) |
| 4201 | |
| 4202 | def test_unstack_errors(self) -> None: |
| 4203 | ds = Dataset({"x": [1, 2, 3]}) |
nothing calls this directly
no test coverage detected