home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 525610905

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/3271#issuecomment-525610905 https://api.github.com/repos/pydata/xarray/issues/3271 525610905 MDEyOklzc3VlQ29tbWVudDUyNTYxMDkwNQ== 1217238 2019-08-28T06:58:40Z 2019-08-28T06:58:40Z MEMBER

ValueError: conflicting sizes for dimension 'x': length 0 on the data but length 4 on coordinate 'x' seems like an improvement, but I'm still not sure it's the right message.

Maybe something like ValueError: different number of dimensions on data and dims: 0 vs 3 would be more precise?

I think this could be achieved by checking len(dims) == len(shape) in the case where dims was explicitly provided, i.e., around this line: https://github.com/pydata/xarray/blob/aaeea6250b89e3605ee1d1a160ad50d6ed657c7e/xarray/core/dataarray.py#L117

For reference, here's the current traceback for this error: ``` In [3]: xr.DataArray(np.array(1), coords={'x': np.arange(4), 'y': 'a'}, dims=['x'])


KeyError Traceback (most recent call last) <ipython-input-3-68fe094298fd> in <module> ----> 1 xr.DataArray(np.array(1), coords={'x': np.arange(4), 'y': 'a'}, dims=['x'])

~/dev/xarray/xarray/core/dataarray.py in init(self, data, coords, dims, name, attrs, encoding, indexes, fastpath) 344 data = _check_data_shape(data, coords, dims) 345 data = as_compatible_data(data) --> 346 coords, dims = _infer_coords_and_dims(data.shape, coords, dims) 347 variable = Variable(dims, data, attrs, encoding, fastpath=True) 348

~/dev/xarray/xarray/core/dataarray.py in _infer_coords_and_dims(shape, coords, dims) 140 141 for d, s in zip(v.dims, v.shape): --> 142 if s != sizes[d]: 143 raise ValueError( 144 "conflicting sizes for dimension %r: "

KeyError: 'x' ```

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  486153978
Powered by Datasette · Queries took 0.871ms · About: xarray-datasette