MCPcopy Index your code
hub / github.com/pydata/xarray / reduce

Method reduce

xarray/computation/rolling.py:848–898  ·  view source on GitHub ↗

Reduce the items in this group by applying `func` along some dimension(s). Parameters ---------- func : callable Function which can be called in the form `func(x, **kwargs)` to return the result of collapsing an np.ndarray over the

(
        self,
        func: Callable,
        keep_attrs: bool | None = None,
        sliding_window_view_kwargs: Mapping[Any, Any] | None = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

846 return Dataset(reduced, coords=self.obj.coords, attrs=attrs)
847
848 def reduce(
849 self,
850 func: Callable,
851 keep_attrs: bool | None = None,
852 sliding_window_view_kwargs: Mapping[Any, Any] | None = None,
853 **kwargs: Any,
854 ) -> DataArray:
855 """Reduce the items in this group by applying `func` along some
856 dimension(s).
857
858 Parameters
859 ----------
860 func : callable
861 Function which can be called in the form
862 `func(x, **kwargs)` to return the result of collapsing an
863 np.ndarray over the rolling dimension.
864 keep_attrs : bool, default: None
865 If True, the attributes (``attrs``) will be copied from the original
866 object to the new one. If False, the new object will be returned
867 without attributes. If None uses the global default.
868 sliding_window_view_kwargs : Mapping
869 Keyword arguments that should be passed to the underlying array type's
870 ``sliding_window_view`` function.
871 **kwargs : dict
872 Additional keyword arguments passed on to `func`.
873
874 Returns
875 -------
876 reduced : DataArray
877 Array with summarized data.
878
879 See Also
880 --------
881 numpy.lib.stride_tricks.sliding_window_view
882 dask.array.lib.stride_tricks.sliding_window_view
883
884 Notes
885 -----
886 With dask arrays, it's possible to pass the ``automatic_rechunk`` kwarg as
887 ``sliding_window_view_kwargs={"automatic_rechunk": True}``. This controls
888 whether dask should automatically rechunk the output to avoid
889 exploding chunk sizes. Automatically rechunking is the default behaviour.
890 Importantly, each chunk will be a view of the data so large chunk sizes are
891 only safe if *no* copies are made later.
892 """
893 return self._dataset_implementation(
894 functools.partial(DataArrayRolling.reduce, func=func),
895 keep_attrs=keep_attrs,
896 sliding_window_view_kwargs=sliding_window_view_kwargs,
897 **kwargs,
898 )
899
900 def _counts(self, keep_attrs: bool | None) -> Dataset:
901 return self._dataset_implementation(

Callers 1

reduceMethod · 0.45

Calls 1

Tested by

no test coverage detected