From d1143c103c27f59e0c657b6921d2b58155c87f22 Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 19 Feb 2021 15:37:01 +0100 Subject: [PATCH 1/7] explicitly state that update works inplace --- xarray/core/dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 066a2f690b0..2b201b34a01 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -3863,7 +3863,7 @@ def unstack( return result def update(self, other: "CoercibleMapping") -> "Dataset": - """Update this dataset's variables with those from another dataset. + """Update this dataset's variables with those from another dataset inplace. Parameters ---------- From 27d73ed9346db105a7c0196d786081caeb51159e Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 19 Feb 2021 15:43:00 +0100 Subject: [PATCH 2/7] point to assign --- xarray/core/dataset.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 2b201b34a01..22e90d2102f 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -3886,6 +3886,10 @@ def update(self, other: "CoercibleMapping") -> "Dataset": ValueError If any dimensions would have inconsistent sizes in the updated dataset. + + See Also + -------- + Dataset.assign """ merge_result = dataset_update_method(self, other) return self._replace(inplace=True, **merge_result._asdict()) From 1fffca77cc5f471f9d2e2158c08e373743275daf Mon Sep 17 00:00:00 2001 From: Keewis Date: Fri, 19 Feb 2021 22:23:38 +0100 Subject: [PATCH 3/7] update whats-new.rst [skip-ci] --- doc/whats-new.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 22902963d9c..beb3b999012 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -151,6 +151,8 @@ Documentation - add concat examples and improve combining documentation (:issue:`4620`, :pull:`4645`). By `Ray Bell `_ and `Justus Magin `_. +- explicitly mention that :py:meth:`Dataset.update` updates inplace (:issue:``, :pull:``). + By `Justus Magin `_. Internal Changes ~~~~~~~~~~~~~~~~ From 775d0fea2ac1943e5615173399e19d285431bd4f Mon Sep 17 00:00:00 2001 From: Keewis Date: Sat, 20 Feb 2021 00:19:27 +0100 Subject: [PATCH 4/7] rewrite the docstring [skip-ci] --- xarray/core/dataset.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 22e90d2102f..44a9ddac9a7 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -3863,7 +3863,9 @@ def unstack( return result def update(self, other: "CoercibleMapping") -> "Dataset": - """Update this dataset's variables with those from another dataset inplace. + """Update this dataset's variables with those from another dataset. + + Just like :py:meth:`dict.update` this is a in-place operation. Parameters ---------- From f85ae2c035ddf0991595f49f5ab3b83a865173d7 Mon Sep 17 00:00:00 2001 From: Keewis Date: Sun, 21 Feb 2021 21:47:17 +0100 Subject: [PATCH 5/7] deprecate the return value of Dataset.update --- doc/whats-new.rst | 3 +++ xarray/core/dataset.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 758e1184cac..d5fcef1e637 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -64,6 +64,9 @@ Deprecations For now using ``dim`` issues a ``FutureWarning``. It will be removed in version 0.19.0 (:pull:`3993`). By `Tom Nicholas `_. +- the return value of :py:meth:`Dataset.update` is being deprecated to make it work more + like :py:meth:`dict.update`. + By `Justus Magin `_. New Features diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 44a9ddac9a7..930282a6a57 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -3881,7 +3881,10 @@ def update(self, other: "CoercibleMapping") -> "Dataset": Returns ------- updated : Dataset - Updated dataset. + Updated dataset. Note that since the update is in-place this is the input + dataset. + + Deprecated since 0.17. Raises ------ From f34716fe021e9d00fa364489725e2f80a3f49485 Mon Sep 17 00:00:00 2001 From: Keewis Date: Sun, 21 Feb 2021 21:48:36 +0100 Subject: [PATCH 6/7] add the issue and pull request numbers [skip-ci] --- doc/whats-new.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index d5fcef1e637..5cff194ee1e 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -65,7 +65,7 @@ Deprecations version 0.19.0 (:pull:`3993`). By `Tom Nicholas `_. - the return value of :py:meth:`Dataset.update` is being deprecated to make it work more - like :py:meth:`dict.update`. + like :py:meth:`dict.update` (:pull:`4932`). By `Justus Magin `_. @@ -165,7 +165,7 @@ Documentation - add concat examples and improve combining documentation (:issue:`4620`, :pull:`4645`). By `Ray Bell `_ and `Justus Magin `_. -- explicitly mention that :py:meth:`Dataset.update` updates inplace (:issue:``, :pull:``). +- explicitly mention that :py:meth:`Dataset.update` updates inplace (:issue:`2951`, :pull:`4932`). By `Justus Magin `_. Internal Changes From 07fdc8cd91c0cfab40cbf189ce2643603fdcfaa1 Mon Sep 17 00:00:00 2001 From: Keewis Date: Mon, 22 Feb 2021 17:13:53 +0100 Subject: [PATCH 7/7] add a ETA for the removal of the return value [skip-ci] --- doc/whats-new.rst | 2 +- xarray/core/dataset.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 5cff194ee1e..59dad0141ef 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -65,7 +65,7 @@ Deprecations version 0.19.0 (:pull:`3993`). By `Tom Nicholas `_. - the return value of :py:meth:`Dataset.update` is being deprecated to make it work more - like :py:meth:`dict.update` (:pull:`4932`). + like :py:meth:`dict.update`. It will be removed in version 0.19.0 (:pull:`4932`). By `Justus Magin `_. diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 930282a6a57..1f8407d6ceb 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -3884,7 +3884,7 @@ def update(self, other: "CoercibleMapping") -> "Dataset": Updated dataset. Note that since the update is in-place this is the input dataset. - Deprecated since 0.17. + It is deprecated since version 0.17 and scheduled to be removed in 0.19. Raises ------