Closed
Description
Since y-day, pint
0.11 was released and it results in a new test failure (in addition to the ones in #3778 and #3779):
____________________________ TestVariable.test_pad _____________________________
self = <xarray.tests.test_units.TestVariable object at 0x7f6bfd8c1b20>
def test_pad(self):
data = np.arange(4 * 3 * 2).reshape(4, 3, 2)
v = self.cls(["x", "y", "z"], data)
xr_args = [{"x": (2, 1)}, {"y": (0, 3)}, {"x": (3, 1), "z": (2, 0)}]
np_args = [
((2, 1), (0, 0), (0, 0)),
((0, 0), (0, 3), (0, 0)),
((3, 1), (0, 0), (2, 0)),
]
for xr_arg, np_arg in zip(xr_args, np_args):
actual = v.pad_with_fill_value(**xr_arg)
expected = np.pad(
np.array(v.data.astype(float)),
np_arg,
mode="constant",
constant_values=np.nan,
)
assert_array_equal(actual, expected)
assert isinstance(actual._data, type(v._data))
# for the boolean array, we pad False
data = np.full_like(data, False, dtype=bool).reshape(4, 3, 2)
v = self.cls(["x", "y", "z"], data)
for xr_arg, np_arg in zip(xr_args, np_args):
> actual = v.pad_with_fill_value(fill_value=False, **xr_arg)
xarray/tests/test_variable.py:813:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xarray/core/variable.py:1210: in pad_with_fill_value
array = np.pad(
<__array_function__ internals>:5: in pad
???
/usr/lib/python3.8/site-packages/pint/quantity.py:1543: in __array_function__
return numpy_wrap("function", func, args, kwargs, types)
/usr/lib/python3.8/site-packages/pint/numpy_func.py:894: in numpy_wrap
return handled[name](*args, **kwargs)
/usr/lib/python3.8/site-packages/pint/numpy_func.py:671: in _pad
kwargs["constant_values"] = _recursive_convert(kwargs["constant_values"], units)
/usr/lib/python3.8/site-packages/pint/numpy_func.py:659: in _recursive_convert
arg = unit._REGISTRY.Quantity(arg, unit)
/usr/lib/python3.8/site-packages/pint/quantity.py:200: in __new__
inst._magnitude = _to_magnitude(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
value = False, force_ndarray = True, force_ndarray_like = False
def _to_magnitude(value, force_ndarray=False, force_ndarray_like=False):
if isinstance(value, (dict, bool)) or value is None:
> raise TypeError("Invalid magnitude for Quantity: {0!r}".format(value))
E TypeError: Invalid magnitude for Quantity: False
/usr/lib/python3.8/site-packages/pint/compat.py:49: TypeError
Metadata
Metadata
Assignees
Labels
No labels