einsum#
- xarray_einstats.einsum(dims, *operands, keep_dims=frozenset({}), out_append='{i}', einsum_kwargs=None, **kwargs)[source]#
Preprocess inputs to call
numpy.einsum
ornumpy.einsum_path
.Usage examples of all arguments is available at the einsum section of the linear algebra module tutorial.
- Parameters:
- dims
list
oflist
ofstr
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.- operands
xarray.DataArray
DataArrays for the operation. Multiple DataArrays are accepted.
- keep_dims
set
, optional Dimensions to exclude from summation unless specifically specified in
dims
- out_append
str
, 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_kwargs
dict
, optional Passed to
numpy.einsum
- kwargs
dict
, optional Passed to
xarray.apply_ufunc
- dims
Notes
Dimensions present in
dims
will be reduced, but unlike {func}`xarray.dot` it does so only for that variable.