Skip to content
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

xarray throws FutureWarning when using .interp method #7177

Closed
4 tasks done
pnsaevik opened this issue Oct 17, 2022 · 2 comments
Closed
4 tasks done

xarray throws FutureWarning when using .interp method #7177

pnsaevik opened this issue Oct 17, 2022 · 2 comments

Comments

@pnsaevik
Copy link

pnsaevik commented Oct 17, 2022

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
@pnsaevik pnsaevik added bug needs triage Issue that has not been reviewed by xarray team member labels Oct 17, 2022
@keewis
Copy link
Collaborator

keewis commented Oct 17, 2022

As far as I remember we fixed this in a more recent version. Can you try upgrading xarray?

@keewis keewis removed needs triage Issue that has not been reviewed by xarray team member bug labels Oct 17, 2022
@pnsaevik
Copy link
Author

I thought I got the newest version of xarray when creating a conda environment from scratch. I see now that this is not the case. Sorry about that!

Upgrading xarray using pip instead of conda fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants