Skip to content

Commit 74ca69a

Browse files
max-sixtydcherian
authored andcommitted
Remove deprecated behavior from dataset.drop docstring (pydata#3451)
* remove deprecated behavior from dataset.drop docstring * remove a few warnings too * actually keep original form but test for warnings
1 parent 43d07b7 commit 74ca69a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

xarray/core/dataset.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3542,7 +3542,6 @@ def drop( # noqa: F811
35423542
----------
35433543
labels : hashable or iterable of hashables
35443544
Name(s) of variables or index labels to drop.
3545-
If dim is not None, labels can be any array-like.
35463545
dim : None or hashable, optional
35473546
Dimension along which to drop index labels. By default (if
35483547
``dim is None``), drops variables rather than index labels.

xarray/tests/test_dataset.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,25 +2117,31 @@ def test_drop_variables(self):
21172117
def test_drop_index_labels(self):
21182118
data = Dataset({"A": (["x", "y"], np.random.randn(2, 3)), "x": ["a", "b"]})
21192119

2120-
actual = data.drop(["a"], "x")
2120+
with pytest.warns(DeprecationWarning):
2121+
actual = data.drop(["a"], "x")
21212122
expected = data.isel(x=[1])
21222123
assert_identical(expected, actual)
21232124

2124-
actual = data.drop(["a", "b"], "x")
2125+
with pytest.warns(DeprecationWarning):
2126+
actual = data.drop(["a", "b"], "x")
21252127
expected = data.isel(x=slice(0, 0))
21262128
assert_identical(expected, actual)
21272129

21282130
with pytest.raises(KeyError):
21292131
# not contained in axis
2130-
data.drop(["c"], dim="x")
2132+
with pytest.warns(DeprecationWarning):
2133+
data.drop(["c"], dim="x")
21312134

2132-
actual = data.drop(["c"], dim="x", errors="ignore")
2135+
with pytest.warns(DeprecationWarning):
2136+
actual = data.drop(["c"], dim="x", errors="ignore")
21332137
assert_identical(data, actual)
21342138

21352139
with pytest.raises(ValueError):
2136-
data.drop(["c"], dim="x", errors="wrong_value")
2140+
with pytest.warns(DeprecationWarning):
2141+
data.drop(["c"], dim="x", errors="wrong_value")
21372142

2138-
actual = data.drop(["a", "b", "c"], "x", errors="ignore")
2143+
with pytest.warns(DeprecationWarning):
2144+
actual = data.drop(["a", "b", "c"], "x", errors="ignore")
21392145
expected = data.isel(x=slice(0, 0))
21402146
assert_identical(expected, actual)
21412147

0 commit comments

Comments
 (0)