diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 12d5cbdc9f3..eb57b4765d0 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -3536,7 +3536,6 @@ def drop( # noqa: F811 ---------- labels : hashable or iterable of hashables Name(s) of variables or index labels to drop. - If dim is not None, labels can be any array-like. dim : None or hashable, optional Dimension along which to drop index labels. By default (if ``dim is None``), drops variables rather than index labels. diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index 006d6881b5a..4b32ce11d89 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -2118,25 +2118,31 @@ def test_drop_variables(self): def test_drop_index_labels(self): data = Dataset({"A": (["x", "y"], np.random.randn(2, 3)), "x": ["a", "b"]}) - actual = data.drop(["a"], "x") + with pytest.warns(DeprecationWarning): + actual = data.drop(["a"], "x") expected = data.isel(x=[1]) assert_identical(expected, actual) - actual = data.drop(["a", "b"], "x") + with pytest.warns(DeprecationWarning): + actual = data.drop(["a", "b"], "x") expected = data.isel(x=slice(0, 0)) assert_identical(expected, actual) with pytest.raises(KeyError): # not contained in axis - data.drop(["c"], dim="x") + with pytest.warns(DeprecationWarning): + data.drop(["c"], dim="x") - actual = data.drop(["c"], dim="x", errors="ignore") + with pytest.warns(DeprecationWarning): + actual = data.drop(["c"], dim="x", errors="ignore") assert_identical(data, actual) with pytest.raises(ValueError): - data.drop(["c"], dim="x", errors="wrong_value") + with pytest.warns(DeprecationWarning): + data.drop(["c"], dim="x", errors="wrong_value") - actual = data.drop(["a", "b", "c"], "x", errors="ignore") + with pytest.warns(DeprecationWarning): + actual = data.drop(["a", "b", "c"], "x", errors="ignore") expected = data.isel(x=slice(0, 0)) assert_identical(expected, actual)