xarray_einstats.einsum#

xarray_einstats.einsum(dims, *operands, keep_dims=frozenset({}), out_append='{i}', einsum_kwargs=None, **kwargs)[source]#

Preprocess inputs to call numpy.einsum or numpy.einsum_path.

Usage examples of all arguments is available at the einsum section of the linear algebra module tutorial.

Parameters
dimslist of list of str

List of lists of dimension names. It must have the same length or be only one item longer than operands. If both have the same length, the generated pattern passed to {func}`numpy.einsum` won’t have -> nor right hand side. Otherwise, the last item is assumed to be the dimension specification of the output DataArray, and it can be an empty list to add -> but no subscripts.

operandsxarray.DataArray

DataArrays for the operation. Multiple DataArrays are accepted.

keep_dimsset, optional

Dimensions to exclude from summation unless specifically specified in dims

out_appendstr, optional

Pattern to append to repeated dimension names in the output (if any). The pattern should contain a substitution for variable i, which indicates the number of the current dimension among the repeated ones. Its default value is "{i}". To keep repeated dimension names use "".

The first occurrence will keep the original name and not use out_append. It will therefore inherit the coordinate values in case there were any.

einsum_kwargsdict, optional

Passed to numpy.einsum

kwargsdict, optional

Passed to xarray.apply_ufunc

Notes

Dimensions present in dims will be reduced, but unlike {func}`xarray.dot` it does so only for that variable.