Skip to content

Commit

Permalink
Add DataArray().drop_attrs() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
j-haacker committed Feb 8, 2025
1 parent e9e59cd commit f3d7414
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xarray/tests/test_dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2991,8 +2991,11 @@ def test_assign_attrs(self) -> None:

def test_drop_attrs(self) -> None:
# Mostly tested in test_dataset.py, but adding a very small test here
da = DataArray([], attrs=dict(a=1, b=2))
coord_ = xr.DataArray([], attrs=dict(d=3, e=4))
da = DataArray([], attrs=dict(a=1, b=2)).assign_coords(dict(coord_=coord_))
assert da.drop_attrs().attrs == {}
assert da.drop_attrs().coord_.attrs == {}
assert da.drop_attrs(deep=False).coord_.attrs == dict(d=3, e=4)

@pytest.mark.parametrize(
"func", [lambda x: x.clip(0, 1), lambda x: np.float64(1.0) * x, np.abs, abs]
Expand Down

0 comments on commit f3d7414

Please sign in to comment.