Skip to content

document update as inplace #4932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/TomNicholas>`_.
- the return value of :py:meth:`Dataset.update` is being deprecated to make it work more
like :py:meth:`dict.update`. It will be removed in version 0.19.0 (:pull:`4932`).
By `Justus Magin <https://github.com/keewis>`_.


New Features
Expand Down Expand Up @@ -162,6 +165,8 @@ Documentation
- add concat examples and improve combining documentation (:issue:`4620`, :pull:`4645`).
By `Ray Bell <https://github.com/raybellwaves>`_ and
`Justus Magin <https://github.com/keewis>`_.
- explicitly mention that :py:meth:`Dataset.update` updates inplace (:issue:`2951`, :pull:`4932`).
By `Justus Magin <https://github.com/keewis>`_.

Internal Changes
~~~~~~~~~~~~~~~~
Expand Down
11 changes: 10 additions & 1 deletion xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3865,6 +3865,8 @@ def unstack(
def update(self, other: "CoercibleMapping") -> "Dataset":
"""Update this dataset's variables with those from another dataset.

Just like :py:meth:`dict.update` this is a in-place operation.

Parameters
----------
other : Dataset or mapping
Expand All @@ -3879,13 +3881,20 @@ 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.

It is deprecated since version 0.17 and scheduled to be removed in 0.19.

Raises
------
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())
Expand Down