helper function to determine values that can be filled when limit is not None
(arr, dim, limit)
| 563 | |
| 564 | |
| 565 | def _get_valid_fill_mask(arr, dim, limit): |
| 566 | """helper function to determine values that can be filled when limit is not |
| 567 | None""" |
| 568 | kw = {dim: limit + 1} |
| 569 | # we explicitly use construct method to avoid copy. |
| 570 | new_dim = utils.get_temp_dimname(arr.dims, "_window") |
| 571 | return ( |
| 572 | arr.isnull() |
| 573 | .rolling(min_periods=1, **kw) |
| 574 | .construct(new_dim, fill_value=False) |
| 575 | .sum(new_dim, skipna=False) |
| 576 | ) <= limit |
| 577 | |
| 578 | |
| 579 | def _localize(obj: T, indexes_coords: SourceDest) -> tuple[T, SourceDest]: |