(self)
| 35 | assert not isinstance(coords["x"], IndexVariable) |
| 36 | |
| 37 | def test_init_from_coords(self) -> None: |
| 38 | expected = Dataset(coords={"foo": ("x", [0, 1, 2])}) |
| 39 | coords = Coordinates(coords=expected.coords) |
| 40 | assert_identical(coords.to_dataset(), expected) |
| 41 | |
| 42 | # test variables copied |
| 43 | assert coords.variables["foo"] is not expected.variables["foo"] |
| 44 | |
| 45 | # test indexes are extracted |
| 46 | expected = Dataset(coords={"x": [0, 1, 2]}) |
| 47 | coords = Coordinates(coords=expected.coords) |
| 48 | assert_identical(coords.to_dataset(), expected) |
| 49 | assert expected.xindexes == coords.xindexes |
| 50 | |
| 51 | # coords + indexes not supported |
| 52 | with pytest.raises( |
| 53 | ValueError, match=r"passing both.*Coordinates.*indexes.*not allowed" |
| 54 | ): |
| 55 | coords = Coordinates( |
| 56 | coords=expected.coords, indexes={"x": PandasIndex([0, 1, 2], "x")} |
| 57 | ) |
| 58 | |
| 59 | def test_init_empty(self) -> None: |
| 60 | coords = Coordinates() |
nothing calls this directly
no test coverage detected