home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 1723889854

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
1723889854 I_kwDOAMm_X85mwHi- 7872 `Dataset.to_array()` throws `IndexError` for empty datasets 1858546 open 0     2 2023-05-24T12:37:44Z 2023-06-20T22:41:02Z   NONE      

What happened?

```

xr.version '2023.4.2' xr.Dataset().to_array() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/mnt/qb/work2/goswami0/gkd021/conda/envs/wb/lib/python3.10/site-packages/xarray/core/dataset.py", line 6114, in to_array data = duck_array_ops.stack([b.data for b in broadcast_vars], axis=0) File "/mnt/qb/work2/goswami0/gkd021/conda/envs/wb/lib/python3.10/site-packages/xarray/core/duck_array_ops.py", line 326, in stack xp = get_array_namespace(arrays[0]) IndexError: list index out of range ```

What did you expect to happen?

The most reasonable way to handle this in my opinion would be to return an empty, i.e. default constructed, xr.DataArray: ```

xr.DataArray() <xarray.DataArray ()> array(nan) ```

Minimal Complete Verifiable Example

No response

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

No response

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.10.9 (main, Jan 11 2023, 15:21:40) [GCC 11.2.0] python-bits: 64 OS: Linux OS-release: 3.10.0-1160.76.1.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.2 libnetcdf: 4.9.1 xarray: 2023.4.2 pandas: 1.5.2 numpy: 1.23.5 scipy: 1.9.3 netCDF4: 1.6.3 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 iris: None bottleneck: 1.3.5 dask: 2022.7.0 distributed: 2022.7.0 matplotlib: 3.6.2 cartopy: 0.21.1 seaborn: None numbagg: None fsspec: 2022.11.0 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 65.6.3 pip: 22.3.1 conda: None pytest: 7.1.2 mypy: None IPython: 8.8.0 sphinx: 5.0.2
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7872/reactions",
    "total_count": 0,
    "+1": 0,
    "-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
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 0.867ms · About: xarray-datasette