issues: 497184021
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
497184021 | MDU6SXNzdWU0OTcxODQwMjE= | 3334 | plot.line fails when plot axis is a 1D coordinate | 35968931 | closed | 0 | 3 | 2019-09-23T15:52:48Z | 2019-09-26T08:51:59Z | 2019-09-26T08:51:59Z | MEMBER | MCVE Code Sample```python import xarray as xr import numpy as np x_coord = xr.DataArray(data=[0.1, 0.2], dims=['x']) t_coord = xr.DataArray(data=[10, 20], dims=['t']) da = xr.DataArray(data=np.array([[0, 1], [5, 9]]), dims=['x', 't'], coords={'x': x_coord, 'time': t_coord}) print(da) da.transpose('time', 'x')
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 This causes bug in other parts of the code - for example I found this by trying to plot this type of dataarray:
(You can get a similar error also with 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? |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/3334/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |