Skip to content

Commit

Permalink
Pass keep_attrs through to _coarsen_cls and _rolling_cls returns (pyd…
Browse files Browse the repository at this point in the history
  • Loading branch information
amcnicho committed Feb 27, 2020
1 parent 5113bf3 commit df1b0dc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ def rolling(
dim: Mapping[Hashable, int] = None,
min_periods: int = None,
center: bool = False,
keep_attrs: bool = None,
**window_kwargs: int,
):
"""
Expand All @@ -758,6 +759,10 @@ def rolling(
setting min_periods equal to the size of the window.
center : boolean, default False
Set the labels at the center of the window.
keep_attrs : bool, optional
If True, the object's attributes (`attrs`) will be copied from
the original object to the new one. If False (default), the new
object will be returned without attributes.
**window_kwargs : optional
The keyword arguments form of ``dim``.
One of dim or window_kwargs must be provided.
Expand Down Expand Up @@ -799,8 +804,11 @@ def rolling(
core.rolling.DataArrayRolling
core.rolling.DatasetRolling
"""
if keep_attrs is None:
keep_attrs = _get_keep_attrs(default=False)

dim = either_dict_or_kwargs(dim, window_kwargs, "rolling")
return self._rolling_cls(self, dim, min_periods=min_periods, center=center)
return self._rolling_cls(self, dim, min_periods=min_periods, center=center, keep_attrs=keep_attrs)

def rolling_exp(
self,
Expand Down Expand Up @@ -914,7 +922,7 @@ def coarsen(

dim = either_dict_or_kwargs(dim, window_kwargs, "coarsen")
return self._coarsen_cls(
self, dim, boundary=boundary, side=side, coord_func=coord_func
self, dim, boundary=boundary, side=side, coord_func=coord_func, keep_attrs=keep_attrs
)

def resample(
Expand Down

0 comments on commit df1b0dc

Please sign in to comment.