From 44fbf9ccdcd15d9fc3f0582e5543f224b4efa022 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sat, 26 Oct 2019 15:02:52 -0400 Subject: [PATCH 1/3] remove deprecated behavior from dataset.drop docstring --- xarray/core/dataset.py | 1 - 1 file changed, 1 deletion(-) 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. From 88863a21777cca0bf055ae78d9cdf959c9bcaaa0 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sat, 26 Oct 2019 15:16:23 -0400 Subject: [PATCH 2/3] remove a few warnings too --- xarray/tests/test_dataset.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index 006d6881b5a..7f6980142e8 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -2118,25 +2118,25 @@ 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") + actual = data.drop(x=["a"]) expected = data.isel(x=[1]) assert_identical(expected, actual) - actual = data.drop(["a", "b"], "x") + actual = data.drop(x=["a", "b"]) expected = data.isel(x=slice(0, 0)) assert_identical(expected, actual) with pytest.raises(KeyError): # not contained in axis - data.drop(["c"], dim="x") + data.drop(x=["c"]) - actual = data.drop(["c"], dim="x", errors="ignore") + actual = data.drop(x=["c"], errors="ignore") assert_identical(data, actual) with pytest.raises(ValueError): data.drop(["c"], dim="x", errors="wrong_value") - actual = data.drop(["a", "b", "c"], "x", errors="ignore") + actual = data.drop(x=["a", "b", "c"], errors="ignore") expected = data.isel(x=slice(0, 0)) assert_identical(expected, actual) From acbe79ef0f0f7c728a11c264b5e602a7057f40fe Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sat, 26 Oct 2019 18:51:08 -0400 Subject: [PATCH 3/3] actually keep original form but test for warnings --- xarray/tests/test_dataset.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index 7f6980142e8..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(x=["a"]) + with pytest.warns(DeprecationWarning): + actual = data.drop(["a"], "x") expected = data.isel(x=[1]) assert_identical(expected, actual) - actual = data.drop(x=["a", "b"]) + 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(x=["c"]) + with pytest.warns(DeprecationWarning): + data.drop(["c"], dim="x") - actual = data.drop(x=["c"], 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(x=["a", "b", "c"], 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)