Skip to content

Commit

Permalink
Add array function/ufunc deferral tests (xref hgrecco#951)
Browse files Browse the repository at this point in the history
  • Loading branch information
jthielen committed Dec 27, 2019
1 parent 5ce5c46 commit fd96093
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pint/testsuite/test_compat_upcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,20 @@ def test_dataarray_inequalities(da):
with pytest.raises(ValueError) as exc:
da > 2
assert "Cannot compare Quantity and <class 'int'>" in str(exc)


def test_array_function_deferral(da):
lower = 2 * ureg.m
upper = 3 * ureg.m
args = (da, lower, upper)
assert (
lower.__array_function__(
np.clip, tuple(set(type(arg) for arg in args)), args, {}
)
is NotImplemented
)


def test_array_ufunc_deferral(da):
lower = 2 * ureg.m
assert lower.__array_ufunc__(np.maximum, "__call__", lower, da) is NotImplemented

0 comments on commit fd96093

Please sign in to comment.