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

Class SlicesWrapNone

dask/array/_array_expr/_slicing.py:432–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430
431
432class SlicesWrapNone(SliceSlicesIntegers):
433 _parameters = ["array", "index", "allow_getitem_optimization", "where_none"]
434
435 @functools.cached_property
436 def chunks(self):
437 return self.expand(super().chunks, (1,))
438
439 @functools.cached_property
440 def expand(self):
441 return expander(self.where_none)
442
443 def _layer(self) -> dict:
444 dsk = super()._layer()
445
446 where_none_orig = list(self.where_none)
447 expand_orig = expander(where_none_orig)
448
449 # Insert ",0" into the key: ('x', 2, 3) -> ('x', 0, 2, 0, 3)
450 dsk2: dict = {}
451 for k, v in dsk.items():
452 if k[0] == self._name:
453 k2 = (self._name,) + self.expand(k[1:], 0)
454 if isinstance(v.args[1], Alias):
455 # positional indexing with newaxis
456 indexer = expand_orig(dsk[v.args[1].key].value[1], None)
457 tok = "shuffle-taker-" + tokenize(indexer)
458 dsk2[tok] = DataNode(tok, (1, indexer))
459 arg = TaskRef(tok)
460 else:
461 arg = expand_orig(v.args[1], None)
462 # raise NotImplementedError
463 dsk2[k2] = Task(k2, v.func, v.args[0], arg)
464 else:
465 dsk2[k] = v
466 return dsk2
467
468
469class TakeUnknownOneChunk(Slice):

Callers 1

slice_with_newaxesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected