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

Method _layer

dask/array/_array_expr/_slicing.py:394–429  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

392 return tuple(map(tuple, new_blockdims))
393
394 def _layer(self) -> dict:
395 # Get a list (for each dimension) of dicts{blocknum: slice()}
396 block_slices = list(
397 map(_slice_1d, self.array.shape, self.array.chunks, self.index)
398 )
399 sorted_block_slices = [sorted(i.items()) for i in block_slices]
400
401 # (in_name, 1, 1, 2), (in_name, 1, 1, 4), (in_name, 2, 1, 2), ...
402 in_names = list(
403 product([self.array._name], *[pluck(0, s) for s in sorted_block_slices])
404 )
405
406 # (out_name, 0, 0, 0), (out_name, 0, 0, 1), (out_name, 0, 1, 0), ...
407 out_names = list(
408 product(
409 [self._name],
410 *[
411 range(len(d))[::-1] if i.step and i.step < 0 else range(len(d))
412 for d, i in zip(block_slices, self.index)
413 if not isinstance(i, Integral)
414 ],
415 )
416 )
417
418 all_slices = list(product(*[pluck(1, s) for s in sorted_block_slices]))
419
420 dsk_out = {
421 out_name: (
422 Task(out_name, getitem, TaskRef(in_name), slices)
423 if not self.allow_getitem_optimization
424 or not all(sl == slice(None, None, None) for sl in slices)
425 else Alias(out_name, in_name)
426 )
427 for out_name, in_name, slices in zip(out_names, in_names, all_slices)
428 }
429 return dsk_out
430
431
432class SlicesWrapNone(SliceSlicesIntegers):

Callers

nothing calls this directly

Calls 5

TaskClass · 0.90
TaskRefClass · 0.90
AliasClass · 0.90
allFunction · 0.85
itemsMethod · 0.45

Tested by

no test coverage detected