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)
| 1209 | |
| 1210 | |
| 1211 | def 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 | |
| 1236 | def parse_assignment_indices(indices, shape): |
searching dependent graphs…