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

Method _lower

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

Source from the content-addressed store, hash-verified

2592 return self
2593
2594 def _lower(self):
2595 if not isinstance(self, BlockwiseHead):
2596 # Lower to Blockwise
2597 npartitions = self.operand("npartitions")
2598 if self.operand("npartitions") > self.frame.npartitions:
2599 raise ValueError(
2600 f"only {self.frame.npartitions} partitions, head received {npartitions}"
2601 )
2602 partitions = self._partitions
2603 if is_index_like(self._meta):
2604 return BlockwiseHeadIndex(
2605 Partitions(self.frame, partitions), self.n, safe=False
2606 )
2607
2608 safe = True if npartitions == 1 and self.frame.npartitions != 1 else False
2609 frame = BlockwiseHead(
2610 Partitions(self.frame, partitions), self.n, npartitions, safe
2611 )
2612 if npartitions != 1:
2613 from dask.dataframe.dask_expr import Repartition
2614
2615 safe = npartitions != self.frame.npartitions and npartitions != -1
2616 frame = BlockwiseHead(
2617 Repartition(frame, new_partitions=1), self.n, 1, safe
2618 )
2619 return frame
2620
2621 @property
2622 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