MCPcopy Index your code
hub / github.com/dask/dask / _check_divisions

Function _check_divisions

dask/dataframe/dask_expr/_expr.py:1675–1702  ·  view source on GitHub ↗
(df, i, division_min, division_max, last)

Source from the content-addressed store, hash-verified

1673
1674
1675def _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
1705class EnforceRuntimeDivisions(Blockwise):

Callers

nothing calls this directly

Calls 4

is_index_likeFunction · 0.85
minMethod · 0.45
maxMethod · 0.45
isnaMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…