MCPcopy Create free account
hub / github.com/dask/dask / slice_with_newaxes

Function slice_with_newaxes

dask/array/_array_expr/_slicing.py:244–267  ·  view source on GitHub ↗

Handle indexing with Nones Strips out Nones then hands off to slice_wrap_lists

(x, index)

Source from the content-addressed store, hash-verified

242
243
244def slice_with_newaxes(x, index):
245 """
246 Handle indexing with Nones
247
248 Strips out Nones then hands off to slice_wrap_lists
249 """
250 # Strip Nones from index
251 index2 = tuple(ind for ind in index if ind is not None)
252 where_none = [i for i, ind in enumerate(index) if ind is None]
253 for i, xx in enumerate(where_none):
254 n = sum(isinstance(ind, Integral) for ind in index[:xx])
255 if n:
256 where_none[i] -= n
257
258 # Pass down and do work
259 x = slice_wrap_lists(x, index2, not where_none)
260
261 if where_none:
262 return SlicesWrapNone(
263 x.array, x.index, x.allow_getitem_optimization, where_none
264 )
265
266 else:
267 return x
268
269
270def slice_wrap_lists(x, index, allow_getitem_optimization):

Callers 1

slice_arrayFunction · 0.70

Calls 3

SlicesWrapNoneClass · 0.85
slice_wrap_listsFunction · 0.70
sumFunction · 0.50

Tested by

no test coverage detected