einsum#
- xarray_einstats.einsum(dims, *operands, keep_dims=frozenset({}), out_append='{i}', einsum_kwargs=None, **kwargs)[source]#
Expose
numpy.einsum
with an xarray-like API.Usage examples of all arguments is available at the einsum section of the linear algebra module tutorial.
- Parameters:
- dims
str
orlist
oflist
ofstr
If dims is a string it is intepreted as the subscripts for the summation as dimension names. Spaces indicate multiple dimensions in a DataArray and commas indicate multiple DataArray operands. Only dimensions with no spaces, nor commas nor
->
characters are valid.If dims is a list it is interpreted as 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. In this case 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.