155
155
DsCompatible ,
156
156
ErrorOptions ,
157
157
ErrorOptionsWithWarn ,
158
+ GroupIndices ,
158
159
GroupInput ,
159
160
InterpOptions ,
160
161
JoinOptions ,
@@ -3238,7 +3239,7 @@ def sel(
3238
3239
result = self .isel (indexers = query_results .dim_indexers , drop = drop )
3239
3240
return result ._overwrite_indexes (* query_results .as_tuple ()[1 :])
3240
3241
3241
- def _shuffle (self , dim , * , indices : list [ list [ int ]] , chunks : T_Chunks ) -> Self :
3242
+ def _shuffle (self , dim , * , indices : GroupIndices , chunks : T_Chunks ) -> Self :
3242
3243
# Shuffling is only different from `isel` for chunked arrays.
3243
3244
# Extract them out, and treat them specially. The rest, we route through isel.
3244
3245
# This makes it easy to ensure correct handling of indexes.
@@ -3249,14 +3250,22 @@ def _shuffle(self, dim, *, indices: list[list[int]], chunks: T_Chunks) -> Self:
3249
3250
}
3250
3251
subset = self [[name for name in self ._variables if name not in is_chunked ]]
3251
3252
3253
+ no_slices : list [list [int ]] = [
3254
+ list (range (* idx .indices (self .sizes [dim ])))
3255
+ if isinstance (idx , slice )
3256
+ else idx
3257
+ for idx in indices
3258
+ ]
3259
+ no_slices = [idx for idx in no_slices if idx ]
3260
+
3252
3261
shuffled = (
3253
3262
subset
3254
3263
if dim not in subset .dims
3255
- else subset .isel ({dim : np .concatenate (indices )})
3264
+ else subset .isel ({dim : np .concatenate (no_slices )})
3256
3265
)
3257
3266
for name , var in is_chunked .items ():
3258
3267
shuffled [name ] = var ._shuffle (
3259
- indices = indices ,
3268
+ indices = no_slices ,
3260
3269
dim = dim ,
3261
3270
chunks = chunks ,
3262
3271
)
0 commit comments