File tree 1 file changed +12
-3
lines changed 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -157,8 +157,11 @@ def identity(x: T) -> T:
157
157
return x
158
158
159
159
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 ())
162
165
163
166
164
167
def _is_arg_reduction (func : T_Agg ) -> bool :
@@ -2484,7 +2487,13 @@ def groupby_reduce(
2484
2487
has_dask = is_duck_dask_array (array ) or is_duck_dask_array (by_ )
2485
2488
has_cubed = is_duck_cubed_array (array ) or is_duck_cubed_array (by_ )
2486
2489
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
+ ):
2488
2497
# Let's try rechunking for sorted 1D by.
2489
2498
(single_axis ,) = axis_
2490
2499
array = rechunk_for_blockwise (array , single_axis , by_ )
You can’t perform that action at this time.
0 commit comments