Skip to content

Commit

Permalink
Grouper refactor (#9122)
Browse files Browse the repository at this point in the history
* Move Groupers out to groupers.py

* cleanup

* missed one.
  • Loading branch information
dcherian authored Jun 14, 2024
1 parent 1265310 commit 599b779
Show file tree
Hide file tree
Showing 7 changed files with 423 additions and 381 deletions.
3 changes: 2 additions & 1 deletion xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,8 @@ def _resample(
# TODO support non-string indexer after removing the old API.

from xarray.core.dataarray import DataArray
from xarray.core.groupby import ResolvedGrouper, TimeResampler
from xarray.core.groupby import ResolvedGrouper
from xarray.core.groupers import TimeResampler
from xarray.core.resample import RESAMPLE_DIM

# note: the second argument (now 'skipna') use to be 'dim'
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -6751,9 +6751,9 @@ def groupby(
from xarray.core.groupby import (
DataArrayGroupBy,
ResolvedGrouper,
UniqueGrouper,
_validate_groupby_squeeze,
)
from xarray.core.groupers import UniqueGrouper

_validate_groupby_squeeze(squeeze)
rgrouper = ResolvedGrouper(UniqueGrouper(), group, self)
Expand Down Expand Up @@ -6833,11 +6833,11 @@ def groupby_bins(
.. [1] http://pandas.pydata.org/pandas-docs/stable/generated/pandas.cut.html
"""
from xarray.core.groupby import (
BinGrouper,
DataArrayGroupBy,
ResolvedGrouper,
_validate_groupby_squeeze,
)
from xarray.core.groupers import BinGrouper

_validate_groupby_squeeze(squeeze)
grouper = BinGrouper(
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10301,9 +10301,9 @@ def groupby(
from xarray.core.groupby import (
DatasetGroupBy,
ResolvedGrouper,
UniqueGrouper,
_validate_groupby_squeeze,
)
from xarray.core.groupers import UniqueGrouper

_validate_groupby_squeeze(squeeze)
rgrouper = ResolvedGrouper(UniqueGrouper(), group, self)
Expand Down Expand Up @@ -10384,11 +10384,11 @@ def groupby_bins(
.. [1] http://pandas.pydata.org/pandas-docs/stable/generated/pandas.cut.html
"""
from xarray.core.groupby import (
BinGrouper,
DatasetGroupBy,
ResolvedGrouper,
_validate_groupby_squeeze,
)
from xarray.core.groupers import BinGrouper

_validate_groupby_squeeze(squeeze)
grouper = BinGrouper(
Expand Down
Loading

0 comments on commit 599b779

Please sign in to comment.