From fd960931d6d70a6755d146cdcc11ad1bb59964bf Mon Sep 17 00:00:00 2001 From: Jon Thielen Date: Fri, 27 Dec 2019 13:48:56 -0600 Subject: [PATCH] Add array function/ufunc deferral tests (xref #951) --- pint/testsuite/test_compat_upcast.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pint/testsuite/test_compat_upcast.py b/pint/testsuite/test_compat_upcast.py index 108582e7b..7e3cd1023 100644 --- a/pint/testsuite/test_compat_upcast.py +++ b/pint/testsuite/test_compat_upcast.py @@ -108,3 +108,20 @@ def test_dataarray_inequalities(da): with pytest.raises(ValueError) as exc: da > 2 assert "Cannot compare Quantity and " 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