Closed
Description
What happened:
Our doctests fail since numpy 1.20 came out:
https://github.com/pydata/xarray/pull/4760/checks?check_run_id=1818512841#step:8:69
What you expected to happen:
They don't ;-)
Minimal Complete Verifiable Example:
The following fails with numpy 1.20 while it converted np.NaN
to an integer before (xarray.DataArray.pad at the bottom)
import numpy as np
x = np.arange(10)
x = np.pad(x, 1, "constant", constant_values=np.nan)
requires numpy 1.20
Anything else we need to know?:
- that's probably related to https://numpy.org/doc/stable/release/1.20.0-notes.html#numpy-scalars-are-cast-when-assigned-to-arrays
- I asked if this behavior will stay: BUG: numpy.pad pad constant is cast to input array dtype numpy/numpy#16499 (comment)
- One possibility is to add a check
np.can_cast(constant_values.dtype, array.dtype)
(or similar) for a better error message.