MCPcopy Index your code
hub / github.com/pydata/xarray / test_init_from_coords

Method test_init_from_coords

xarray/tests/test_coordinates.py:37–57  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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()

Callers

nothing calls this directly

Calls 5

to_datasetMethod · 0.95
DatasetClass · 0.90
CoordinatesClass · 0.90
assert_identicalFunction · 0.90
PandasIndexClass · 0.90

Tested by

no test coverage detected