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

Method _lower

dask/dataframe/dask_expr/_expr.py:2575–2600  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2573 return self
2574
2575 def _lower(self):
2576 if not isinstance(self, BlockwiseHead):
2577 # Lower to Blockwise
2578 npartitions = self.operand("npartitions")
2579 if self.operand("npartitions") > self.frame.npartitions:
2580 raise ValueError(
2581 f"only {self.frame.npartitions} partitions, head received {npartitions}"
2582 )
2583 partitions = self._partitions
2584 if is_index_like(self._meta):
2585 return BlockwiseHeadIndex(
2586 Partitions(self.frame, partitions), self.n, safe=False
2587 )
2588
2589 safe = True if npartitions == 1 and self.frame.npartitions != 1 else False
2590 frame = BlockwiseHead(
2591 Partitions(self.frame, partitions), self.n, npartitions, safe
2592 )
2593 if npartitions != 1:
2594 from dask.dataframe.dask_expr import Repartition
2595
2596 safe = npartitions != self.frame.npartitions and npartitions != -1
2597 frame = BlockwiseHead(
2598 Repartition(frame, new_partitions=1), self.n, 1, safe
2599 )
2600 return frame
2601
2602 @property
2603 def _partitions(self):

Callers

nothing calls this directly

Calls 6

RepartitionClass · 0.90
is_index_likeFunction · 0.85
BlockwiseHeadIndexClass · 0.85
PartitionsClass · 0.85
BlockwiseHeadClass · 0.85
operandMethod · 0.80

Tested by

no test coverage detected