home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 511477827

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
511477827 MDU6SXNzdWU1MTE0Nzc4Mjc= 3437 Request error handling in dataarray construction 3274 open 0     4 2019-10-23T17:48:11Z 2020-01-08T21:14:27Z   CONTRIBUTOR      

When I have a bad dimension in an xarray I get this error:

ValueError: different number of dimensions on data and dims: 2 vs 3

Expected Output

what I would like to see is

ValueError: different number of dimensions on data and dims: 2 vs 3 for variable Foo

The improvement I am asking for is here: https://github.com/pydata/xarray/blob/c8dac5866d2c54ee6b262b5060a701e0be1e40cb/xarray/core/dataarray.py#L368-L371

What I claim would be an improvement would be something like this: data = _check_data_shape(data, coords, dims) data = as_compatible_data(data) try: coords, dims = _infer_coords_and_dims(data.shape, coords, dims) except Exception as e: if name: raise Exception("Error finding coordinates and dims for variable %s: %s"%(name, e) else: raise e variable = Variable(dims, data, attrs, encoding, fastpath=True)

I'm not an expert on python exception handling, so this is probably wrong.

Problem Description

The programmer cannot tell what variable causes the shape and dimension issue.

Output of xr.show_versions()

python: 3.6.8 (default, Sep 6 2019, 11:45:11) [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] python-bits: 64 OS: Darwin OS-release: 18.7.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.2 libnetcdf: 4.6.3 xarray: 0.13.0 pandas: 0.25.2 numpy: 1.17.3 scipy: 1.3.1 netCDF4: 1.5.2 pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: None cftime: 1.0.3.4 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: None distributed: None matplotlib: 3.1.1 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 41.2.0 pip: 19.3.1 conda: None pytest: 5.2.0 IPython: 7.8.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3437/reactions",
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 0.559ms · About: xarray-datasette