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

Method _lower

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

Source from the content-addressed store, hash-verified

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