(
self,
array_agg_func,
bottleneck_move_func,
numbagg_move_func,
rolling_agg_func,
keep_attrs,
fillna,
**kwargs,
)
| 693 | ) |
| 694 | |
| 695 | def _array_reduce( |
| 696 | self, |
| 697 | array_agg_func, |
| 698 | bottleneck_move_func, |
| 699 | numbagg_move_func, |
| 700 | rolling_agg_func, |
| 701 | keep_attrs, |
| 702 | fillna, |
| 703 | **kwargs, |
| 704 | ): |
| 705 | if "dim" in kwargs: |
| 706 | warnings.warn( |
| 707 | f"Reductions are applied along the rolling dimension(s) " |
| 708 | f"'{self.dim}'. Passing the 'dim' kwarg to reduction " |
| 709 | f"operations has no effect.", |
| 710 | FutureWarning, |
| 711 | stacklevel=3, |
| 712 | ) |
| 713 | del kwargs["dim"] |
| 714 | |
| 715 | xp = duck_array_ops.get_array_namespace(self.obj.data) |
| 716 | if ( |
| 717 | OPTIONS["use_numbagg"] |
| 718 | and module_available("numbagg") |
| 719 | and numbagg_move_func is not None |
| 720 | # TODO: we could at least allow this for the equivalent of `apply_ufunc`'s |
| 721 | # "parallelized". `rolling_exp` does this, as an example (but rolling_exp is |
| 722 | # much simpler) |
| 723 | and not is_duck_dask_array(self.obj.data) |
| 724 | # Numbagg doesn't handle object arrays and generally has dtype consistency, |
| 725 | # so doesn't deal well with bool arrays which are expected to change type. |
| 726 | and self.obj.data.dtype.kind not in "ObMm" |
| 727 | # TODO: we could also allow this, probably as part of a refactoring of this |
| 728 | # module, so we can use the machinery in `self.reduce`. |
| 729 | and self.ndim == 1 |
| 730 | and xp is np |
| 731 | ): |
| 732 | import numbagg |
| 733 | |
| 734 | # Numbagg has a default ddof of 1. I (@max-sixty) think we should make |
| 735 | # this the default in xarray too, but until we do, don't use numbagg for |
| 736 | # std and var unless ddof is set to 1. |
| 737 | if ( |
| 738 | numbagg_move_func not in [numbagg.move_std, numbagg.move_var] |
| 739 | or kwargs.get("ddof") == 1 |
| 740 | ): |
| 741 | return self._numbagg_reduce( |
| 742 | numbagg_move_func, keep_attrs=keep_attrs, **kwargs |
| 743 | ) |
| 744 | |
| 745 | if ( |
| 746 | OPTIONS["use_bottleneck"] |
| 747 | and bottleneck_move_func is not None |
| 748 | and ( |
| 749 | not is_duck_dask_array(self.obj.data) |
| 750 | or module_available("dask", "2024.11.0") |
| 751 | ) |
| 752 | and self.ndim == 1 |
nothing calls this directly
no test coverage detected