-
|
I am trying to understand the behavior of xarray (in comparison with numpy arrays and sparse matrices). I have simplified my case below to a 2D problem to show the problem. I think that there must be a simple solution but am breaking my head around it. Therefore, any help would be most appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
if you look at the In [5]: aXr = xr.DataArray(a, dims=("a", "b"))
...: bXr = xr.DataArray(b, dims=("b", "c"))
...: aXr @ bXr
Out[5]:
<xarray.DataArray (a: 10, c: 5)>
array([[10., 10., 10., 10., 10.],
[10., 10., 10., 10., 10.],
[10., 10., 10., 10., 10.],
[10., 10., 10., 10., 10.],
[10., 10., 10., 10., 10.],
[10., 10., 10., 10., 10.],
[10., 10., 10., 10., 10.],
[10., 10., 10., 10., 10.],
[10., 10., 10., 10., 10.],
[10., 10., 10., 10., 10.]])
Dimensions without coordinates: a, cnote that having multiple dimensions with the same name is not supported (i.e. |
Beta Was this translation helpful? Give feedback.
if you look at the
DataArrayobjects, the dimension names (arr.dims) are("dim0", "dim1")for both objects. SinceaXrandbXrhave different shapes, the matrix multiplication fails. To fix this, you can add dimension names: