(df, i, division_min, division_max, last)
| 1673 | |
| 1674 | |
| 1675 | def _check_divisions(df, i, division_min, division_max, last): |
| 1676 | if not len(df): |
| 1677 | return df |
| 1678 | if is_index_like(df): |
| 1679 | index = df |
| 1680 | else: |
| 1681 | try: |
| 1682 | index = df.index.get_level_values(0) |
| 1683 | except AttributeError: |
| 1684 | index = df.index |
| 1685 | # Check divisions |
| 1686 | real_min = index.min() |
| 1687 | real_max = index.max() |
| 1688 | # Upper division of the last partition is often set to |
| 1689 | # the max value. For all other partitions, the upper |
| 1690 | # division should be greater than the maximum value. |
| 1691 | valid_min = valid_max = True |
| 1692 | if not pd.isna(division_min): |
| 1693 | valid_min = real_min >= division_min |
| 1694 | if not pd.isna(division_max): |
| 1695 | valid_max = (real_max <= division_max) if last else (real_max < division_max) |
| 1696 | if not (valid_min and valid_max): |
| 1697 | raise RuntimeError( |
| 1698 | f"`enforce_runtime_divisions` failed for partition {i}." |
| 1699 | f" Expected a range of [{division_min}, {division_max}), " |
| 1700 | f" but the real range was [{real_min}, {real_max}]." |
| 1701 | ) |
| 1702 | return df |
| 1703 | |
| 1704 | |
| 1705 | class EnforceRuntimeDivisions(Blockwise): |
nothing calls this directly
no test coverage detected
searching dependent graphs…