From ac97a75e4991bf1e8f5a3616ecd18874f9de67d5 Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 23 Jul 2021 00:53:08 +0200 Subject: [PATCH] remove the deprecated return value of Dataset.update --- xarray/core/dataset.py | 12 ++---------- xarray/tests/test_dataset.py | 6 +++--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 13da8cfad03..8604b031039 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -4157,7 +4157,7 @@ def unstack( result = result._unstack_once(dim, fill_value) return result - def update(self, other: "CoercibleMapping") -> "Dataset": + def update(self, other: "CoercibleMapping") -> None: """Update this dataset's variables with those from another dataset. Just like :py:meth:`dict.update` this is a in-place operation. @@ -4173,14 +4173,6 @@ def update(self, other: "CoercibleMapping") -> "Dataset": - mapping {var name: (dimension name, array-like)} - mapping {var name: (tuple of dimension names, array-like)} - Returns - ------- - updated : Dataset - Updated dataset. Note that since the update is in-place this is the input - dataset. - - It is deprecated since version 0.17 and scheduled to be removed in 0.19. - Raises ------ ValueError @@ -4192,7 +4184,7 @@ def update(self, other: "CoercibleMapping") -> "Dataset": Dataset.assign """ merge_result = dataset_update_method(self, other) - return self._replace(inplace=True, **merge_result._asdict()) + self._replace(inplace=True, **merge_result._asdict()) def merge( self, diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index 7ee80c0e8f6..803daac42df 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -3191,13 +3191,13 @@ def test_update(self): data = create_test_data(seed=0) expected = data.copy() var2 = Variable("dim1", np.arange(8)) - actual = data.update({"var2": var2}) + actual = data.copy() + actual.update({"var2": var2}) expected["var2"] = var2 assert_identical(expected, actual) actual = data.copy() - actual_result = actual.update(data) - assert actual_result is actual + actual.update(data) assert_identical(expected, actual) other = Dataset(attrs={"new": "attr"})