Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4184,6 +4184,12 @@ def _validate_interp_indexer(x, new_x):
variables: dict[Hashable, Variable] = {}
reindex: bool = False
for name, var in obj._variables.items():
if var.isnull().any():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah we can't do this really. I thought the behaviour stemmed from NaNs in the coordinate. Scanning the whole array like this is going to be expensive in many cases.

emit_user_level_warning(
"Interpolation behavior with NaNs is inconsistent. Consider using"
" .dropna() or .interpna()."
)

if name in indexers:
continue

Expand Down
4 changes: 3 additions & 1 deletion xarray/tests/test_interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,9 @@ def test_nans(use_dask: bool) -> None:
pytest.skip("dask is not installed in the environment.")
da = da.chunk()

actual = da.interp(x=[0.5, 1.5])
with pytest.warns(UserWarning, match=r"^Interpolation behavior"):
actual = da.interp(x=[0.5, 1.5])

# not all values are nan
assert actual.count() > 0

Expand Down