Skip to content

Commit

Permalink
Add support for attrs to DataArray()._replace
Browse files Browse the repository at this point in the history
  • Loading branch information
j-haacker committed Feb 9, 2025
1 parent cfcaffa commit f2175fe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,10 @@ def _replace(
name = self.name
if attrs is _default:
attrs = copy.copy(self.attrs)
return type(self)(variable, coords, name=name, attrs=attrs, indexes=indexes, fastpath=True)
else:
variable = self.variable.copy()
setattr(variable, "attrs", attrs)
return type(self)(variable, coords, name=name, indexes=indexes, fastpath=True)

def _replace_maybe_drop_dims(
self,
Expand Down

0 comments on commit f2175fe

Please sign in to comment.