issue_comments: 321119003
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/pydata/xarray/pull/1473#issuecomment-321119003 | https://api.github.com/repos/pydata/xarray/issues/1473 | 321119003 | MDEyOklzc3VlQ29tbWVudDMyMTExOTAwMw== | 6815844 | 2017-08-09T00:32:46Z | 2017-08-09T00:32:46Z | MEMBER | Another case I am wondering is when indexing-DataArray has the same name but different valued coordinate, ```python In [1]: import numpy as np ...: import xarray as xr ...: ...: da = xr.DataArray(np.arange(3 * 2).reshape(3, 2), dims=['x', 'y'], ...: coords={'x': [0, 1, 2], 'y': ['a', 'b']}) ...: da # indexed DataArray ...: Out[1]: <xarray.DataArray (x: 3, y: 2)> array([[0, 1], [2, 3], [4, 5]]) Coordinates: * x (x) int64 0 1 2 * y (y) <U1 'a' 'b' In [2]: ind = xr.DataArray([2, 1], dims=['x'], coords={'x': [0.1, 0.2]}) ...: ind # indexing DataArray. This also has 'x' ...: Out[2]: <xarray.DataArray (x: 2)> array([2, 1]) Coordinates: * x (x) float64 0.1 0.2 In [3]: da.isel(x=ind.variable) ...: Out[3]: <xarray.DataArray (x: 2, y: 2)> array([[4, 5], [2, 3]]) Coordinates: * x (x) int64 2 1 * y (y) <U1 'a' 'b' In [4]: da.isel(x=ind) # Overwrite da['x'] by ind['x'] ...: Out[4]: <xarray.DataArray (x: 2, y: 2)> array([[4, 5], [2, 3]]) Coordinates: * x (x) float64 0.1 0.2 * y (y) <U1 'a' 'b' ``` Currently, the original coordinate is overwritten by the indexer's coordinate, but it may cause an unintentional change of the coordinate values. May be we should keep the original coordinate in such a case or raise an Exception? |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
241578773 |