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

Use complex nan by default when interpolating out of bounds #6019

Merged
merged 4 commits into from
Nov 28, 2021

Conversation

pums974
Copy link
Contributor

@pums974 pums974 commented Nov 23, 2021

  • Tests added
  • Passes pre-commit run --all-files
  • User visible changes (including notable bug fixes) are documented in whats-new.rst

When using the da.interp to interpolate outside of the bounds, by default, fill_value is set to np.nan to set the values to NaN.
This is completely fine with real values, but with complex values this will in fact set the values to np.nan + 0j which can be a source of confusion and bugs.
This PR propose to detect if values are complex, and if so, to use np.nan + np.nan*1j as the default fill_value

xarray/core/missing.py Outdated Show resolved Hide resolved
Copy link
Contributor

@dcherian dcherian left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @pums974

@dcherian dcherian added the plan to merge Final call for comments label Nov 24, 2021
@dcherian dcherian merged commit fb01c72 into pydata:main Nov 28, 2021
dcherian added a commit to dcherian/xarray that referenced this pull request Dec 2, 2021
* upstream/main:
  fix grammatical typo in docs (pydata#6034)
  Use condas dask-core in ci instead of dask to speedup ci and reduce dependencies (pydata#6007)
  Use complex nan by default when interpolating out of bounds (pydata#6019)
  Simplify missing value handling in xarray.corr (pydata#6025)
  Add pyXpcm to Related Projects doc page (pydata#6031)
  Make xr.corr and xr.map_blocks work without dask (pydata#5731)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan to merge Final call for comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants