Skip to content

Commit c62ad44

Browse files
authored
Remove None output from _get_expected_groups (#152)
* Remove raise_if_dask * remove argument in in code. * Update core.py * Update core.py * Update core.py * Update core.py * Update core.py * Missed a if ! * Update core.py * Update core.py
1 parent 2b54c5e commit c62ad44

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

flox/core.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@ def _is_arg_reduction(func: str | Aggregation) -> bool:
5454
return False
5555

5656

57-
def _get_expected_groups(by, sort, *, raise_if_dask=True) -> pd.Index | None:
57+
def _get_expected_groups(by, sort: bool) -> pd.Index:
5858
if is_duck_dask_array(by):
59-
if raise_if_dask:
60-
raise ValueError("Please provide expected_groups if not grouping by a numpy array.")
61-
return None
59+
raise ValueError("Please provide expected_groups if not grouping by a numpy array.")
6260
flatby = by.reshape(-1)
6361
expected = pd.unique(flatby[~isnull(flatby)])
6462
return _convert_expected_groups_to_index((expected,), isbin=(False,), sort=sort)[0]
@@ -1152,7 +1150,10 @@ def dask_groupby_agg(
11521150
else:
11531151
intermediate = applied
11541152
if expected_groups is None:
1155-
expected_groups = _get_expected_groups(by_input, sort=sort, raise_if_dask=False)
1153+
if is_duck_dask_array(by_input):
1154+
expected_groups = None
1155+
else:
1156+
expected_groups = _get_expected_groups(by_input, sort=sort)
11561157
group_chunks = ((len(expected_groups),) if expected_groups is not None else (np.nan,),)
11571158

11581159
if method == "map-reduce":

flox/xarray.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def xarray_reduce(
313313
f"Please provided bin edges for group variable {idx} "
314314
f"named {group_name} in expected_groups."
315315
)
316-
expect_ = _get_expected_groups(b_.data, sort=sort, raise_if_dask=True)
316+
expect_ = _get_expected_groups(b_.data, sort=sort)
317317
else:
318318
expect_ = expect
319319
expect_index = _convert_expected_groups_to_index((expect_,), (isbin_,), sort=sort)[0]

0 commit comments

Comments
 (0)