`coords.update()` converts CuPy arrays to NumPy for dimension coordinates
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
What is your issue?
When assigning CuPy arrays as coordinates to a dataset using DataSet.coords.update(), the resulting coordinate data is converted to a NumPy array.
As a result, GPU-native workflows that are dependent on coordinates (e.g. grid interpolation) become CPU-bound or require additional data transfers to the GPU.
Minimal example:
data_cp = cp.arange(6)
ds = xr.Dataset({
"var": (("x"), data_cp)
})
x_cp = cp.array([0,1,2,3,4,5])
print(type(x_cp)) # <class 'cupy.ndarray'>
ds.coords.update({"x": x_cp.copy()})
print(type(ds.coords["x"].data)) # <class 'numpy.ndarray'>
xarray: 2026.2.0
Question
Is this conversion intended, or should CuPy-backed coordinates be supported?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the minimal example at the DataSet.coords.update() entry point and inspect how the assigned coordinate data is handled. Trace where the CuPy array becomes a NumPy array, then determine the intended behavior and add a regression test showing the resulting coordinate type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100