issues: 2180430069
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2180430069 | I_kwDOAMm_X86B9rj1 | 8820 | "ValueError: dimensions [...] must have the same length as the number of data dimensions" when slicing by zero-dimensional CuPy array | 404832 | open | 0 | 0 | 2024-03-11T23:21:34Z | 2024-03-11T23:21:34Z | CONTRIBUTOR | What happened?I'm slicing a DataArray by another zero-dimensional array. It works as I would expect when the DataArray and indexing array are backed by NumPy, but not when they're CuPy arrays:
which results in:
What did you expect to happen?If the example is run with NumPy arrays instead of CuPy arrays, we get this, as expected:
Minimal Complete Verifiable Example```Python !/usr/bin/env python3import cupy as cp import xarray as xr a = xr.DataArray(cp.arange(24).reshape(4, 6), dims=['x', 'y']) idx = xr.DataArray(cp.array(2)) print(a.isel(x=idx)) ``` MVCE confirmation
Relevant log output
Anything else we need to know?I briefly looked into this but haven't discovered the cause yet. What I know:
- It appears the buggy behavior was introduced in version 2023.3.0. With 2023.2.0, it gives the correct output.
- I confirmed in the debugger that the indexing operation itself seems to work, and it's really just the dimensions Environment
INSTALLED VERSIONS
------------------
commit: None
python: 3.11.8 (main, Feb 25 2024, 16:41:26) [GCC 9.4.0]
python-bits: 64
OS: Linux
OS-release: 5.15.0-100-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: None
libnetcdf: None
xarray: 2024.2.0
pandas: 1.5.3
numpy: 1.26.4
scipy: None
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: 13.0.0
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: None
pip: None
conda: None
pytest: None
mypy: None
IPython: None
sphinx: None
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/8820/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |