xarray.DataArray.dot

DataArray.dot(self, other: 'DataArray', dims: Union[Hashable, Sequence[Hashable], NoneType] = None) → 'DataArray'

Perform dot product of two DataArrays along their shared dims.

Equivalent to taking taking tensordot over all shared dims.

Parameters
  • other (DataArray) – The other array with which the dot product is performed.

  • dims (hashable or sequence of hashables, optional) – Along which dimensions to be summed over. Default all the common dimensions are summed over.

Returns

result – Array resulting from the dot product over all shared dimensions.

Return type

DataArray

See also

dot(), numpy.tensordot()

Examples

>>> da_vals = np.arange(6 * 5 * 4).reshape((6, 5, 4))
>>> da = DataArray(da_vals, dims=['x', 'y', 'z'])
>>> dm_vals = np.arange(4)
>>> dm = DataArray(dm_vals, dims=['z'])
>>> dm.dims
('z')
>>> da.dims
('x', 'y', 'z')
>>> dot_result = da.dot(dm)
>>> dot_result.dims
('x', 'y')