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 957918751,MDU6SXNzdWU5NTc5MTg3NTE=,5664,Interpolation behaviour inconsistent with numpy? ,7017525,open,0,,,4,2021-08-02T08:56:28Z,2024-03-12T01:15:46Z,,NONE,,,,"Hey all, When running `dataset.interp(time=dataset.time)` fills with `np.nan` if one of the neighbor is a `np.nan` **even when interpolation is not actually needed**. Here is the sample code to reproduce the issue : ```python def test_crop_times_nan() : ds = xr.Dataset( data_vars = { ""some_variable"" : (['x', 'time'], np.array([[np.nan, 0, 1]])) }, coords = { ""time"" : np.array([0,1,2]) } ) result = ds.interp(time=ds.time) # result[""some_variable""].value == [nan, nan, 1.0] # whereas [nan, 0, 1.0] is EXPECTED xr.testing.assert_allclose(ds, result) ``` Please note that numpy does not have the same behavior : ```python >>> import numpy as np >>> np.interp([0,1,2], xp=[0,1,2], fp=[np.nan,0,1]) array([nan, 0., 1.]) ``` Is that an intended behaviour for xarray? If so, does this mean that I first have to check if an interpolation is needed instead of doing it no matter what (and use `reindex` instead of `interp` if it is not needed) ? (this will be kind of tricky if interpolation is needed for certain values and some not...) Thanks for your help ;) **Environment**:
Output of xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] python-bits: 64 OS: Linux OS-release: 5.8.0-7642-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.0 libnetcdf: 4.7.4 xarray: 0.18.2 pandas: 1.2.4 numpy: 1.19.4 scipy: 1.6.0 netCDF4: 1.5.6 pydap: None h5netcdf: 0.8.1 h5py: 3.1.0 Nio: None zarr: None cftime: 1.3.0 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2021.01.0 distributed: 2021.01.0 matplotlib: 3.4.2 cartopy: None seaborn: None numbagg: None pint: None setuptools: 57.4.0 pip: 20.2.4 conda: None pytest: None IPython: 7.19.0 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5664/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue