(self)
| 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): |
nothing calls this directly
no test coverage detected