Use either bottleneck or numbagg depending on options & what's available
(array, n: int | None = None, axis: int = -1)
| 861 | |
| 862 | |
| 863 | def _push(array, n: int | None = None, axis: int = -1): |
| 864 | """ |
| 865 | Use either bottleneck or numbagg depending on options & what's available |
| 866 | """ |
| 867 | |
| 868 | if not OPTIONS["use_bottleneck"] and not OPTIONS["use_numbagg"]: |
| 869 | raise RuntimeError( |
| 870 | "ffill & bfill requires bottleneck or numbagg to be enabled." |
| 871 | " Call `xr.set_options(use_bottleneck=True)` or `xr.set_options(use_numbagg=True)` to enable one." |
| 872 | ) |
| 873 | if OPTIONS["use_numbagg"] and module_available("numbagg"): |
| 874 | import numbagg # type: ignore[import-not-found, unused-ignore] |
| 875 | |
| 876 | return numbagg.ffill(array, limit=n, axis=axis) |
| 877 | |
| 878 | # work around for bottleneck 178 |
| 879 | limit = n if n is not None else array.shape[axis] |
| 880 | |
| 881 | import bottleneck as bn |
| 882 | |
| 883 | return bn.push(array, limit, axis) |
| 884 | |
| 885 | |
| 886 | def push(array, n, axis, method="blelloch"): |
no test coverage detected
searching dependent graphs…