Skip to content

Potential bug in interp #10325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
5 tasks done
bbabenko opened this issue May 14, 2025 · 1 comment
Open
5 tasks done

Potential bug in interp #10325

bbabenko opened this issue May 14, 2025 · 1 comment
Labels
bug needs triage Issue that has not been reviewed by xarray team member

Comments

@bbabenko
Copy link

What happened?

There seems to be an issue with dtypes when calling interp on dask-backed data arrays.

Example:

da = xr.DataArray(
    data=dask.array.array([1, 2, 3], dtype=np.float32),
    dims=("x"),
    coords={"x": np.array([0, 1, 2], dtype=np.float32)},
)
da = da.interp(x=np.array([0.75], dtype=np.float64))
print(da.dtype, da.compute().dtype, da.astype(np.float32).compute().dtype)

this prints out:

float32 float64 float64

so, not only is there a difference before/after compute(), explicitly casting to float32 doesn't seem to have an effect.

What did you expect to happen?

No response

Minimal Complete Verifiable Example

MVCE confirmation

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

Relevant log output

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS

commit: None
python: 3.11.8 (stable, redacted, redacted) [Clang 9999.0.0 (799e9053641a6478d3144866a97737b37b87c260)]
python-bits: 64
OS: Linux
OS-release: 5.10.0-smp-1105.47.0.0
machine: x86_64
processor:
byteorder: little
LC_ALL: en_US.UTF-8
LANG: None
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.3
libnetcdf: 4.6.1

xarray: 2025.01.2
pandas: 2.2.3
numpy: 2.2.4
scipy: 1.13.1
netCDF4: 1.6.5
pydap: None
h5netcdf: 999
h5py: 3.11.0
zarr: 2.18.2
cftime: 1.6.4
nc_time_axis: None
iris: None
bottleneck: None
dask: 2024.8.2
distributed: None
matplotlib: 3.9.1
cartopy: 0+unknown
seaborn: 0.12.2
numbagg: None
fsspec: 2023.3.0
cupy: None
pint: 0.24.3
sparse: None
flox: None
numpy_groupies: None
setuptools: 0.dev0+unknown
pip: None
conda: None
pytest: None
mypy: None
IPython: 7.34.0
sphinx: None

@bbabenko bbabenko added bug needs triage Issue that has not been reviewed by xarray team member labels May 14, 2025
Copy link

welcome bot commented May 14, 2025

Thanks for opening your first issue here at xarray! Be sure to follow the issue template!
If you have an idea for a solution, we would really welcome a Pull Request with proposed changes.
See the Contributing Guide for more.
It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage Issue that has not been reviewed by xarray team member
Projects
None yet
Development

No branches or pull requests

1 participant