MCPcopy
hub / github.com/dask/dask / shuffle_slice

Function shuffle_slice

dask/array/slicing.py:1211–1233  ·  view source on GitHub ↗

A relatively efficient way to shuffle `x` according to `index`. Parameters ---------- x : Array index : ndarray This should be an ndarray the same length as `x` containing each index position in ``range(0, len(x))``. Returns ------- Array

(x, index)

Source from the content-addressed store, hash-verified

1209
1210
1211def shuffle_slice(x, index):
1212 """A relatively efficient way to shuffle `x` according to `index`.
1213
1214 Parameters
1215 ----------
1216 x : Array
1217 index : ndarray
1218 This should be an ndarray the same length as `x` containing
1219 each index position in ``range(0, len(x))``.
1220
1221 Returns
1222 -------
1223 Array
1224 """
1225 from dask.array.core import PerformanceWarning
1226
1227 chunks1 = chunks2 = x.chunks
1228 if x.ndim > 1:
1229 chunks1 = (chunks1[0],)
1230 index2, index3 = make_block_sorted_slices(index, chunks1)
1231 with warnings.catch_warnings():
1232 warnings.simplefilter("ignore", PerformanceWarning)
1233 return x[index2].rechunk(chunks2)[index3]
1234
1235
1236def parse_assignment_indices(indices, shape):

Callers 5

permutationMethod · 0.90
permutationMethod · 0.90
test_shuffle_sliceFunction · 0.90
permutationMethod · 0.90
permutationMethod · 0.90

Calls 2

make_block_sorted_slicesFunction · 0.85
rechunkMethod · 0.45

Tested by 1

test_shuffle_sliceFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…