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

Method test_drop_index_labels

xarray/tests/test_dataarray.py:2977–2990  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2975 assert key not in actual.xindexes
2976
2977 def test_drop_index_labels(self) -> None:
2978 arr = DataArray(np.random.randn(2, 3), coords={"y": [0, 1, 2]}, dims=["x", "y"])
2979 actual = arr.drop_sel(y=[0, 1])
2980 expected = arr[:, 2:]
2981 assert_identical(actual, expected)
2982
2983 with pytest.raises((KeyError, ValueError), match=r"not .* in axis"):
2984 actual = arr.drop_sel(y=[0, 1, 3])
2985
2986 actual = arr.drop_sel(y=[0, 1, 3], errors="ignore")
2987 assert_identical(actual, expected)
2988
2989 with pytest.warns(FutureWarning):
2990 arr.drop([0, 1, 3], dim="y", errors="ignore") # type: ignore[arg-type]
2991
2992 def test_drop_index_positions(self) -> None:
2993 arr = DataArray(np.random.randn(2, 3), dims=["x", "y"])

Callers

nothing calls this directly

Calls 4

drop_selMethod · 0.95
dropMethod · 0.95
DataArrayClass · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected