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