Skip to content

Commit

Permalink
Removed raise ValueError from previous commit
Browse files Browse the repository at this point in the history
It seems that np.min/max works in place of nanmin/nanmax for datetime types for numpy < 1.18, see https://github.com/pydata/xarray/pull/3924/files
  • Loading branch information
jenssss committed Aug 25, 2020
1 parent 80e07cb commit 8313c3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ Bug fixes
- Fix :py:func:`xarray.apply_ufunc` with ``vectorize=True`` and ``exclude_dims`` (:issue:`3890`).
By `Mathias Hauser <https://github.com/mathause>`_.
- Fix `KeyError` when doing linear interpolation to an nd `DataArray`
that contains NaNs (:pull:`4233`). Requires `numpy` version `1.18`
or newer to work with datetime indices.
that contains NaNs (:pull:`4233`).
By `Jens Svensmark <https://github.com/jenssss>`_

Documentation
Expand Down
11 changes: 4 additions & 7 deletions xarray/core/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,13 +554,10 @@ def _localize(var, indexes_coords):
if np.issubdtype(new_x.dtype, np.datetime64) and LooseVersion(
np.__version__
) < LooseVersion("1.18"):
if new_x.isnull().any():
raise ValueError(
"numpy 1.18 or newer required to use interp with datetime/ timedelta array containing missing values"
)
else:
minval = np.min(new_x.values)
maxval = np.max(new_x.values)
# np.nanmin/max changed behaviour for datetime types in numpy 1.18,
# see https://github.com/pydata/xarray/pull/3924/files
minval = np.min(new_x.values)
maxval = np.max(new_x.values)
else:
minval = np.nanmin(new_x.values)
maxval = np.nanmax(new_x.values)
Expand Down

0 comments on commit 8313c3e

Please sign in to comment.