diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_nep50_promotions.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/numpy/core/tests/test_nep50_promotions.py b/numpy/core/tests/test_nep50_promotions.py index 220482dcc..4bc034920 100644 --- a/numpy/core/tests/test_nep50_promotions.py +++ b/numpy/core/tests/test_nep50_promotions.py @@ -4,7 +4,10 @@ mode. Most of these test are likely to be simply deleted again once NEP 50 is adopted in the main test suite. A few may be moved elsewhere. """ +import operator + import numpy as np + import pytest @@ -123,6 +126,25 @@ def test_nep50_weak_integers_with_inexact(dtype): assert res == np.inf +@pytest.mark.parametrize("op", [operator.add, operator.pow, operator.eq]) +def test_weak_promotion_scalar_path(op): + # Some additional paths excercising the weak scalars. + np._set_promotion_state("weak") + + # Integer path: + res = op(np.uint8(3), 5) + assert res == op(3, 5) + assert res.dtype == np.uint8 or res.dtype == bool + + with pytest.raises(OverflowError): + op(np.uint8(3), 1000) + + # Float path: + res = op(np.float32(3), 5.) + assert res == op(3., 5.) + assert res.dtype == np.float32 or res.dtype == bool + + def test_nep50_complex_promotion(): np._set_promotion_state("weak") |