Skip to content

xarray throws FutureWarning when using .interp method #7177

Closed
@pnsaevik

Description

@pnsaevik

What happened?

I get a FutureWarning when using the .interp method on an xarray.DataArray

The issue is probably related to #6625, #5721 and #6195.

Steps to reproduce

  1. conda create -n test xarray scipy
  2. conda activate test
  3. python -c "import xarray; xarray.DataArray([1., 2.]).interp(dim_0=0.5)"

Expected output

Nothing

Actual output

C:\Miniconda3\envs\test\lib\site-packages\xarray\core\missing.py:562: FutureWarning: Passing method to Int64Index.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead.
imin = index.get_loc(minval, method="nearest")
C:\Miniconda3\envs\test\lib\site-packages\xarray\core\missing.py:563: FutureWarning: Passing method to Int64Index.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead.
imax = index.get_loc(maxval, method="nearest")

What did you expect to happen?

I expected no warning

Minimal Complete Verifiable Example

import xarray
xarray.DataArray([1., 2.]).interp(dim_0=0.5)

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.

Relevant log output

C:\Miniconda3\envs\test\lib\site-packages\xarray\core\missing.py:562: FutureWarning: Passing method to Int64Index.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead.
  imin = index.get_loc(minval, method="nearest")
C:\Miniconda3\envs\test\lib\site-packages\xarray\core\missing.py:563: FutureWarning: Passing method to Int64Index.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead.
  imax = index.get_loc(maxval, method="nearest")

Anything else we need to know?

No response

Environment

C:\Miniconda3\envs\test\lib\site-packages\_distutils_hack\__init__.py:33: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")

INSTALLED VERSIONS
------------------
commit: None
python: 3.10.6 | packaged by conda-forge | (main, Oct  7 2022, 20:14:50) [MSC v.1916 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 158 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: ('Norwegian Bokmål_Norway', '1252')
libhdf5: None
libnetcdf: None

xarray: 0.20.1
pandas: 1.4.4
numpy: 1.23.1
scipy: 1.9.1
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.5
dask: None
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: None
sparse: None
setuptools: 63.4.1
pip: 22.2.2
conda: None
pytest: None
IPython: None
sphinx: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions