home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1652227927

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
1652227927 I_kwDOAMm_X85iev9X 7713 `Variable/IndexVariable` do not accept a tuple for data. 44142765 closed 0     4 2023-04-03T14:50:58Z 2023-04-28T14:26:37Z 2023-04-28T14:26:37Z NONE      

What happened?

It appears that Variable and IndexVariable do not accept a tuple for the data parameter even though the docstring suggests it should be able to accept array_like objects (tuple falls under this type of object, right?).

What did you expect to happen?

Successful instantiation of a Variable/IndexVariable object, but instead a ValueError exception is raised.

Minimal Complete Verifiable Example

```Python import xarray as xr

xr.Variable(data=(2, 3, 45), dims="day") ```

MVCE confirmation

  • [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • [X] Complete example — the example is self-contained, including all data and the text of any traceback.
  • [X] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • [x] New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

Python ValueError: dimensions ('day',) must have the same length as the number of data dimensions, ndim=0

Anything else we need to know?

This error seems to be triggered by the self._parse_dimensions(dims) call inside the Variable class. This problem does not happen if I use a list. But I find it strange that the array_like data specifically needs to be a certain type of object for the call to work. Maybe if it has to be a list then the docstring should reflect that.

Environment

``` INSTALLED VERSIONS ------------------ commit: None python: 3.8.16 | packaged by conda-forge | (default, Feb 1 2023, 16:01:55) [GCC 11.3.0] python-bits: 64 OS: Linux OS-release: 6.1.21-1-lts machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.2 libnetcdf: 4.8.1 xarray: 2023.1.0 pandas: 1.5.3 numpy: 1.23.5 scipy: 1.10.1 netCDF4: 1.6.2 pydap: None h5netcdf: 1.1.0 h5py: 3.8.0 Nio: None zarr: 2.14.2 cftime: 1.6.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2023.3.2 distributed: 2023.3.2 matplotlib: None cartopy: None seaborn: None numbagg: None fsspec: 2023.3.0 cupy: None pint: None sparse: 0.14.0 flox: None numpy_groupies: None setuptools: 67.6.1 pip: 23.0.1 conda: None pytest: 7.2.2 mypy: 1.1.1 IPython: 8.12.0 sphinx: None ```
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7713/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

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