xarray_einstats.einops.raw_reduce(da, pattern, reduction, **kwargs)[source]#

Crudely wrap einops.reduce.

Wrapper around einops.reduce with a very similar syntax. Spaces, parenthesis () and -> are not allowed in dimension names.


Input array


Pattern string. Same syntax as patterns in einops with two caveats:

  • Unless splitting or stacking, you must use the actual dimension names.

  • When splitting or stacking you can use (dim1 dim2)=dim. This is necessary for the left hand side as it identifies the dimension to split, and optional on the right hand side, if omitted the stacked dimension will be given a default name.

reductionstr or callable

One of available reductions (‘min’, ‘max’, ‘sum’, ‘mean’, ‘prod’) by einops.reduce, case-sensitive. Alternatively, a callable f(tensor, reduced_axes) -> tensor can be provided. reduced_axes are passed as a list of int.

kwargsdict, optional

Passed to xarray_einstats.einops.reduce


See also


More flexible and powerful wrapper over einops.reduce. It is also more verbose.

xarray_einstats.einops.rename_kwarg, xarray_einstats.einops.raw_rearrange