You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<xarray.DataArray (x: 2, t: 2)>
array([[0, 1],
[5, 9]])
Coordinates:
* x (x) float64 0.1 0.2
time (t) int64 10 20
Traceback (most recent call last):
File "mwe.py", line 22, in <module>
da.transpose('time', 'x')
File "/home/tegn500/Documents/Work/Code/xarray/xarray/core/dataarray.py", line 1877, in transpose
"permuted array dimensions (%s)" % (dims, tuple(self.dims))
ValueError: arguments to transpose (('time', 'x')) must be permuted array dimensions (('x', 't'))
As 'time' is a coordinate with only one dimension, this is an unambiguous operation that I want to perform. However, because .transpose() currently only accepts dimensions, this fails with that error.
This causes bug in other parts of the code - for example I found this by trying to plot this type of dataarray:
da.plot(x='time', hue='x')
which gives the same error.
(You can get a similar error also with da.plot(y='time', hue='x').)
If the code which explicitly checks that the arguments to transpose are dims and not just coordinate dimensions is removed, then both of these examples work as expected.
I would like to generalise the transpose function to also accept dimension coordinates, is there any reason not to do this?
The text was updated successfully, but these errors were encountered:
MCVE Code Sample
Output:
As
'time'
is a coordinate with only one dimension, this is an unambiguous operation that I want to perform. However, because.transpose()
currently only accepts dimensions, this fails with that error.This causes bug in other parts of the code - for example I found this by trying to plot this type of dataarray:
which gives the same error.
(You can get a similar error also with
da.plot(y='time', hue='x')
.)If the code which explicitly checks that the arguments to transpose are dims and not just coordinate dimensions is removed, then both of these examples work as expected.
I would like to generalise the transpose function to also accept dimension coordinates, is there any reason not to do this?
The text was updated successfully, but these errors were encountered: