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