Skip to content

Commit b6d767d

Browse files
committed
Fix
1 parent e3b8092 commit b6d767d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

flox/core.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,11 @@ def identity(x: T) -> T:
157157
return x
158158

159159

160-
def _issorted(arr: np.ndarray) -> bool:
161-
return bool((arr[:-1] <= arr[1:]).all())
160+
def _issorted(arr: np.ndarray, ascending=True) -> bool:
161+
if ascending:
162+
return bool((arr[:-1] <= arr[1:]).all())
163+
else:
164+
return bool((arr[:-1] >= arr[1:]).all())
162165

163166

164167
def _is_arg_reduction(func: T_Agg) -> bool:
@@ -2484,7 +2487,13 @@ def groupby_reduce(
24842487
has_dask = is_duck_dask_array(array) or is_duck_dask_array(by_)
24852488
has_cubed = is_duck_cubed_array(array) or is_duck_cubed_array(by_)
24862489

2487-
if method is None and not any_by_dask and by_.ndim == 1 and _issorted(by_):
2490+
if (
2491+
method is None
2492+
and is_duck_dask_array(array)
2493+
and not any_by_dask
2494+
and by_.ndim == 1
2495+
and _issorted(by_, ascending=True)
2496+
):
24882497
# Let's try rechunking for sorted 1D by.
24892498
(single_axis,) = axis_
24902499
array = rechunk_for_blockwise(array, single_axis, by_)

0 commit comments

Comments
 (0)