Skip to content

Commit

Permalink
TST: Cover additional NEP 50 scalar paths
Browse files Browse the repository at this point in the history
Especially adding coverage also for the power operator which
does not share its code perfectly.
  • Loading branch information
seberg committed Sep 12, 2022
1 parent ede4ca4 commit bae8510
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions numpy/core/tests/test_nep50_promotions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
is adopted in the main test suite. A few may be moved elsewhere.
"""

import operator

import numpy as np

import pytest


Expand Down Expand Up @@ -123,6 +126,19 @@ 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")

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)


def test_nep50_complex_promotion():
np._set_promotion_state("weak")

Expand Down

0 comments on commit bae8510

Please sign in to comment.