Skip to content

Commit

Permalink
remove the deprecated return value of Dataset.update
Browse files Browse the repository at this point in the history
  • Loading branch information
keewis committed Jul 23, 2021
1 parent c6b33e6 commit 5cc85c8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
12 changes: 2 additions & 10 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ def test_more_transforms_pass_lazy_array_equiv(map_da, map_ds):
assert_equal(xr.broadcast(map_ds.cxy, map_ds.cxy)[0], map_ds.cxy)
assert_equal(map_ds.map(lambda x: x), map_ds)
assert_equal(map_ds.set_coords("a").reset_coords("a"), map_ds)
assert_equal(map_ds.update({"a": map_ds.a}), map_ds)
assert_equal(map_ds.assign({"a": map_ds.a}), map_ds)

# fails because of index error
# assert_equal(
Expand Down
6 changes: 3 additions & 3 deletions xarray/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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"})
Expand Down

0 comments on commit 5cc85c8

Please sign in to comment.