MCPcopy Index your code
hub / github.com/dask/dask / slice_array

Function slice_array

dask/array/_array_expr/_slicing.py:225–241  ·  view source on GitHub ↗

slice_with_newaxis : handle None/newaxis case slice_wrap_lists : handle fancy indexing with lists slice_slices_and_integers : handle everything else

(x, index)

Source from the content-addressed store, hash-verified

223
224
225def slice_array(x, index):
226 """
227 slice_with_newaxis : handle None/newaxis case
228 slice_wrap_lists : handle fancy indexing with lists
229 slice_slices_and_integers : handle everything else
230 """
231 if all(
232 isinstance(index, slice) and index == slice(None, None, None) for index in index
233 ):
234 # all none slices
235 return x.expr
236
237 # Add in missing colons at the end as needed. x[5] -> x[5, :, :]
238 not_none_count = sum(i is not None for i in index)
239 missing = len(x.chunks) - not_none_count
240 index += (slice(None, None, None),) * missing
241 return slice_with_newaxes(x, index)
242
243
244def slice_with_newaxes(x, index):

Callers 9

test_slice_array_1dFunction · 0.90
test_slice_array_2dFunction · 0.90
test_slice_optimizationsFunction · 0.90
test_slicing_chunksFunction · 0.90
test_uneven_blockdimsFunction · 0.90
__getitem__Method · 0.90

Calls 3

allFunction · 0.85
slice_with_newaxesFunction · 0.70
sumFunction · 0.50

Tested by 8

test_slice_array_1dFunction · 0.72
test_slice_array_2dFunction · 0.72
test_slice_optimizationsFunction · 0.72
test_slicing_chunksFunction · 0.72
test_uneven_blockdimsFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…