(
self,
arg: str | list[str],
drop: bool,
dropped: list[str],
converted: list[str],
renamed: dict[str, str],
)
| 3979 | ], |
| 3980 | ) |
| 3981 | def test_reset_index_drop_convert( |
| 3982 | self, |
| 3983 | arg: str | list[str], |
| 3984 | drop: bool, |
| 3985 | dropped: list[str], |
| 3986 | converted: list[str], |
| 3987 | renamed: dict[str, str], |
| 3988 | ) -> None: |
| 3989 | # regressions https://github.com/pydata/xarray/issues/6946 and |
| 3990 | # https://github.com/pydata/xarray/issues/6989 |
| 3991 | # check that multi-index dimension or level coordinates are dropped, converted |
| 3992 | # from IndexVariable to Variable or renamed to dimension as expected |
| 3993 | midx = pd.MultiIndex.from_product([["a", "b"], [1, 2]], names=("foo", "bar")) |
| 3994 | midx_coords = Coordinates.from_pandas_multiindex(midx, "x") |
| 3995 | ds = xr.Dataset(coords=midx_coords) |
| 3996 | reset = ds.reset_index(arg, drop=drop) |
| 3997 | |
| 3998 | for name in dropped: |
| 3999 | assert name not in reset.variables |
| 4000 | for name in converted: |
| 4001 | assert_identical(reset[name].variable, ds[name].variable.to_base_variable()) |
| 4002 | for old_name, new_name in renamed.items(): |
| 4003 | assert_identical(ds[old_name].variable, reset[new_name].variable) |
| 4004 | |
| 4005 | def test_reorder_levels(self) -> None: |
| 4006 | ds = create_test_multiindex() |
nothing calls this directly
no test coverage detected