home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 128903340

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
128903340 MDU6SXNzdWUxMjg5MDMzNDA= 727 DataArray creation prone to errors when data shares dimension shapes 1839645 closed 0     10 2016-01-26T18:32:54Z 2016-09-01T22:14:31Z 2016-09-01T21:56:02Z MEMBER      

It seems like there would be unexpected behavior whenever someone creates a DataArray using data with some subset of dimensions that have the same shape, and when supplying coords as a dictionary of coord_name: coords pairs. Since the dictionary isn't ordered, won't it be unclear which dimension it is referring to?

Maybe that's not such a good description, here's an example:

``` python data = np.random.randn(20, 5, 5) da = xarray.DataArray(data, {'1': np.arange(20), '2': np.arange(15, 20), '3': np.arange(5, 10)}) print(da.coords)

da = xarray.DataArray(data, {'10': np.arange(20), '11': np.arange(15, 20), '12': np.arange(5, 10)}) print(da.coords) ```

For the first dimension it's no problem, since it's the only one with length 20. For the 2nd and 3rd dimensions since they are the same shape, the coordinates will be assigned depending on which order python takes the keys, which means they could sometimes be flipped depending on something arbitrary like what you named a dimension.

It seems like this could be addressed by doing a quick check (when supplying coordinates in this fashion) to see if any of the dimensions of the coordinates are the same, and throwing a warning that behavior might be unstable. Or maybe it throws an error and says "if data coordinates are same length, please supply coordinate values in a tuple or list instead"?

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/727/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 10 rows from issue in issue_comments
Powered by Datasette · Queries took 0.6ms · About: xarray-datasette