(self)
| 4170 | ds.stack(z=["x", "y"], create_index=True) |
| 4171 | |
| 4172 | def test_stack_non_dim_coords(self) -> None: |
| 4173 | ds = Dataset( |
| 4174 | data_vars={"b": (("x", "y"), [[0, 1], [2, 3]])}, |
| 4175 | coords={"x": ("x", [0, 1]), "y": ["a", "b"]}, |
| 4176 | ).rename_vars(x="xx") |
| 4177 | |
| 4178 | exp_index = pd.MultiIndex.from_product([[0, 1], ["a", "b"]], names=["xx", "y"]) |
| 4179 | exp_coords = Coordinates.from_pandas_multiindex(exp_index, "z") |
| 4180 | expected = Dataset(data_vars={"b": ("z", [0, 1, 2, 3])}, coords=exp_coords) |
| 4181 | |
| 4182 | actual = ds.stack(z=["x", "y"]) |
| 4183 | assert_identical(expected, actual) |
| 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"]) |
nothing calls this directly
no test coverage detected