Skip to content

Commit 336e2bb

Browse files
committed
Remove split-reduce to reduce some test time.
1 parent 5431813 commit 336e2bb

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

flox/core.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
T_Dtypes = Union[np.typing.DTypeLike, Sequence[np.typing.DTypeLike], None]
4040
T_FillValues = Union[np.typing.ArrayLike, Sequence[np.typing.ArrayLike], None]
4141
T_Engine = Literal["flox", "numpy", "numba"]
42-
T_MethodCohorts = Literal["cohorts", "split-reduce"]
43-
T_Method = Literal["map-reduce", "blockwise", T_MethodCohorts]
42+
T_Method = Literal["map-reduce", "blockwise", "cohorts"]
4443
T_IsBins = Union[bool | Sequence[bool]]
4544

4645

@@ -161,8 +160,6 @@ def find_group_cohorts(labels, chunks, merge: bool = True):
161160
merge : bool, optional
162161
Attempt to merge cohorts when one cohort's chunks are a subset
163162
of another cohort's chunks.
164-
method : ["split-reduce", "cohorts"], optional
165-
Which method are we using?
166163
167164
Returns
168165
-------
@@ -1243,7 +1240,7 @@ def dask_groupby_agg(
12431240
partial(
12441241
blockwise_method,
12451242
axis=axis,
1246-
expected_groups=None if method in ["split-reduce", "cohorts"] else expected_groups,
1243+
expected_groups=None if method == "cohorts" else expected_groups,
12471244
engine=engine,
12481245
sort=sort,
12491246
),
@@ -1268,7 +1265,7 @@ def dask_groupby_agg(
12681265
(len(expected_groups),) if expected_groups is not None else (np.nan,),
12691266
)
12701267

1271-
if method in ["map-reduce", "cohorts", "split-reduce"]:
1268+
if method in ["map-reduce", "cohorts"]:
12721269
combine: Callable[..., IntermediateDict]
12731270
if do_simple_combine:
12741271
combine = _simple_combine
@@ -1306,7 +1303,7 @@ def dask_groupby_agg(
13061303
expected_groups_ = expected_groups
13071304
groups = (expected_groups_.to_numpy(),)
13081305

1309-
elif method in ["cohorts", "split-reduce"]:
1306+
elif method == "cohorts":
13101307
chunks_cohorts = find_group_cohorts(
13111308
by_input, [array.chunks[ax] for ax in axis], merge=True
13121309
)
@@ -1604,6 +1601,9 @@ def groupby_reduce(
16041601
if method in ["split-reduce", "cohorts"] and by_is_dask:
16051602
raise ValueError(f"method={method!r} can only be used when grouping by numpy arrays.")
16061603

1604+
if method == "split-reduce":
1605+
method = "cohorts"
1606+
16071607
reindex = _validate_reindex(reindex, func, method, expected_groups, by_is_dask)
16081608

16091609
if not is_duck_array(array):
@@ -1634,7 +1634,7 @@ def groupby_reduce(
16341634

16351635
# TODO: could restrict this to dask-only
16361636
factorize_early = (nby > 1) or (
1637-
any(isbins) and method in ["split-reduce", "cohorts"] and is_duck_dask_array(array)
1637+
any(isbins) and method == "cohorts" and is_duck_dask_array(array)
16381638
)
16391639
if factorize_early:
16401640
bys, final_groups, grp_shape = _factorize_multiple(
@@ -1653,7 +1653,7 @@ def groupby_reduce(
16531653
axis_ = np.core.numeric.normalize_axis_tuple(axis, array.ndim) # type: ignore
16541654
nax = len(axis_)
16551655

1656-
if method in ["blockwise", "cohorts", "split-reduce"] and nax != by_.ndim:
1656+
if method in ["blockwise", "cohorts"] and nax != by_.ndim:
16571657
raise NotImplementedError(
16581658
"Must reduce along all dimensions of `by` when method != 'map-reduce'."
16591659
f"Received method={method!r}"

tests/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ def test_npg_nanarg_bug(func):
626626
assert_equal(actual, expected)
627627

628628

629-
@pytest.mark.parametrize("method", ["split-reduce", "cohorts", "map-reduce"])
629+
@pytest.mark.parametrize("method", ["cohorts", "map-reduce"])
630630
@pytest.mark.parametrize("chunk_labels", [False, True])
631631
@pytest.mark.parametrize("chunks", ((), (1,), (2,)))
632632
def test_groupby_bins(chunk_labels, chunks, engine, method) -> None:

0 commit comments

Comments
 (0)