Skip to content

Commit 6298d5c

Browse files
committed
cleanup
1 parent c2b3e80 commit 6298d5c

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

xarray/core/dataarray.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6789,12 +6789,10 @@ def groupby(
67896789
from xarray.core.groupby import (
67906790
DataArrayGroupBy,
67916791
_parse_group_and_groupers,
6792-
_validate_group_and_groupers,
67936792
_validate_groupby_squeeze,
67946793
)
67956794

67966795
_validate_groupby_squeeze(squeeze)
6797-
_validate_group_and_groupers(group, groupers)
67986796
rgroupers = _parse_group_and_groupers(self, group, groupers)
67996797
return DataArrayGroupBy(self, rgroupers, restore_coord_dims=restore_coord_dims)
68006798

xarray/core/dataset.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10385,12 +10385,10 @@ def groupby(
1038510385
from xarray.core.groupby import (
1038610386
DatasetGroupBy,
1038710387
_parse_group_and_groupers,
10388-
_validate_group_and_groupers,
1038910388
_validate_groupby_squeeze,
1039010389
)
1039110390

1039210391
_validate_groupby_squeeze(squeeze)
10393-
_validate_group_and_groupers(group, groupers)
1039410392
rgroupers = _parse_group_and_groupers(self, group, groupers)
1039510393

1039610394
return DatasetGroupBy(self, rgroupers, restore_coord_dims=restore_coord_dims)

xarray/core/groupby.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,19 @@ def _parse_group_and_groupers(
326326
from xarray.core.variable import Variable
327327
from xarray.groupers import UniqueGrouper
328328

329+
if group is not None and groupers:
330+
raise ValueError(
331+
"Providing a combination of `group` and **groupers is not supported."
332+
)
333+
334+
if group is None and not groupers:
335+
raise ValueError("Either `group` or `**groupers` must be provided.")
336+
337+
if isinstance(group, np.ndarray | pd.Index):
338+
raise TypeError(
339+
f"`group` must be a DataArray. Received {type(group).__name__!r} instead"
340+
)
341+
329342
if isinstance(group, Mapping):
330343
grouper_mapping = either_dict_or_kwargs(group, groupers, "groupby")
331344
group = None
@@ -351,21 +364,6 @@ def _parse_group_and_groupers(
351364
return rgroupers
352365

353366

354-
def _validate_group_and_groupers(group: GroupInput, groupers: dict[str, Grouper]):
355-
if group is not None and groupers:
356-
raise ValueError(
357-
"Providing a combination of `group` and **groupers is not supported."
358-
)
359-
360-
if group is None and not groupers:
361-
raise ValueError("Either `group` or `**groupers` must be provided.")
362-
363-
if isinstance(group, np.ndarray | pd.Index):
364-
raise TypeError(
365-
f"`group` must be a DataArray. Received {type(group).__name__!r} instead"
366-
)
367-
368-
369367
def _validate_groupby_squeeze(squeeze: Literal[False]) -> None:
370368
# While we don't generally check the type of every arg, passing
371369
# multiple dimensions as multiple arguments is common enough, and the

0 commit comments

Comments
 (0)