Skip to content

Set keep_attrs for flox #6667

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

Merged
merged 1 commit into from
Jun 6, 2022
Merged
Changes from all 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
6 changes: 5 additions & 1 deletion xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,17 @@ def _maybe_unstack(self, obj):
obj._indexes = filter_indexes_from_coords(obj._indexes, set(obj.coords))
return obj

def _flox_reduce(self, dim, **kwargs):
def _flox_reduce(self, dim, keep_attrs=None, **kwargs):
"""Adaptor function that translates our groupby API to that of flox."""
from flox.xarray import xarray_reduce

from .dataset import Dataset

obj = self._original_obj

if keep_attrs is None:
keep_attrs = _get_keep_attrs(default=False)

# preserve current strategy (approximately) for dask groupby.
# We want to control the default anyway to prevent surprises
# if flox decides to change its default
Expand Down Expand Up @@ -664,6 +667,7 @@ def _flox_reduce(self, dim, **kwargs):
dim=dim,
expected_groups=expected_groups,
isbin=isbin,
keep_attrs=keep_attrs,
**kwargs,
)

Expand Down