Skip to content
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

rolling keep_attrs & default True #4510

Merged
merged 20 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from 12 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
8 changes: 8 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ v0.16.2 (unreleased)
Breaking changes
~~~~~~~~~~~~~~~~

- :py:attr:`DataArray.rolling` and :py:attr:`Dataset.rolling` no longer support passing ``keep_attrs``
via its constructor. Pass ``keep_attrs`` via the applied function, i.e. use
``ds.rolling(...).mean(keep_attrs=False)`` instead of ``ds.rolling(..., keep_attrs=False).mean()``
Rolling operations now keep their attributes per default (:pull:`4510`).
By `Mathias Hauser <https://github.com/mathause>`_.

New Features
~~~~~~~~~~~~
Expand Down Expand Up @@ -50,6 +55,9 @@ Bug fixes
By `Mathias Hauser <https://github.com/mathause>`_.
- :py:func:`combine_by_coords` now raises an informative error when passing coordinates
with differing calendars (:issue:`4495`). By `Mathias Hauser <https://github.com/mathause>`_.
- :py:attr:`DataArray.rolling` and :py:attr:`Dataset.rolling` now also keep the attributes and names of of (wrapped)
``DataArray`` objects, previously only the global attributes were retained (:issue:`4497`, :pull:`4510`).
By `Mathias Hauser <https://github.com/mathause>`_.

Documentation
~~~~~~~~~~~~~
Expand Down
9 changes: 0 additions & 9 deletions xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,13 +577,10 @@ def pipe(

>>> def adder(data, arg):
... return data + arg
mathause marked this conversation as resolved.
Show resolved Hide resolved
...
mathause marked this conversation as resolved.
Show resolved Hide resolved
>>> def div(data, arg):
... return data / arg
mathause marked this conversation as resolved.
Show resolved Hide resolved
...
>>> def sub_mult(data, sub_arg, mult_arg):
... return (data * mult_arg) - sub_arg
mathause marked this conversation as resolved.
Show resolved Hide resolved
...
>>> x.pipe(adder, 2)
<xarray.Dataset>
Dimensions: (lat: 2, lon: 2)
Expand Down Expand Up @@ -811,10 +808,6 @@ def rolling(
setting min_periods equal to the size of the window.
center : bool or mapping, 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 @@ -863,8 +856,6 @@ 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(
Expand Down
Loading