(self)
| 3939 | assert_identical(actual, expected) |
| 3940 | |
| 3941 | def test_reset_index(self) -> None: |
| 3942 | ds = create_test_multiindex() |
| 3943 | mindex = ds["x"].to_index() |
| 3944 | indexes = [mindex.get_level_values(str(n)) for n in mindex.names] |
| 3945 | coords = {idx.name: ("x", idx) for idx in indexes} |
| 3946 | expected = Dataset({}, coords=coords) |
| 3947 | |
| 3948 | obj = ds.reset_index("x") |
| 3949 | assert_identical(obj, expected, check_default_indexes=False) |
| 3950 | assert len(obj.xindexes) == 0 |
| 3951 | |
| 3952 | ds = Dataset(coords={"y": ("x", [1, 2, 3])}) |
| 3953 | with pytest.raises(ValueError, match=r".*not coordinates with an index"): |
| 3954 | ds.reset_index("y") |
| 3955 | |
| 3956 | def test_reset_index_keep_attrs(self) -> None: |
| 3957 | coord_1 = DataArray([1, 2], dims=["coord_1"], attrs={"attrs": True}) |
nothing calls this directly
no test coverage detected