8000 TST: Straight forward NEP 50 fixup or longdouble+int scalar tests · numpy/numpy@ea3428e · GitHub
[go: up one dir, main page]

Skip to content

Commit ea3428e

Browse files
committed
TST: Straight forward NEP 50 fixup or longdouble+int scalar tests
1 parent be03e9b commit ea3428e

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

numpy/core/tests/test_scalarmath.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -898,31 +898,32 @@ def test_operator_scalars(op, type1, type2):
898898

899899

900900
@pytest.mark.parametrize("op", reasonable_operators_for_scalars)
901-
@pytest.mark.parametrize("val", [None, 2**64])
902-
def test_longdouble_inf_loop(op, val):
903-
# Note: The 2**64 value will pass once NEP 50 is adopted.
901+
@pytest.mark.parametrize("sctype", [np.longdouble, np.clongdouble])
902+
def test_longdouble_inf_loop(sctype, op):
904903
try:
905-
op(np.longdouble(3), val)
904+
op(sctype(3), None)
906905
except TypeError:
907906
pass
908907
try:
909-
op(val, np.longdouble(3))
908+
op(None, sctype(3))
910909
except TypeError:
911910
pass
912911

913912

914913
@pytest.mark.parametrize("op", reasonable_operators_for_scalars)
915-
@pytest.mark.parametrize("val", [None, 2**64])
916-
def test_clongdouble_inf_loop(op, val):
917-
# Note: The 2**64 value will pass once NEP 50 is adopted.
918-
try:
919-
op(np.clongdouble(3), val)
920-
except TypeError:
921-
pass
922-
try:
923-
op(val, np.longdouble(3))
924-
except TypeError:
925-
pass
914+
@pytest.mark.parametrize("sctype", [np.longdouble, np.clongdouble])
915+
@np.errstate(all="ignore")
916+
def test_longdouble_inf_loop(sctype, op):
917+
# NEP 50 means that the result is clearly a (c)longdouble here:
918+
if sctype == np.clongdouble and op in [operator.mod, operator.floordiv]:
919+
# The above operators are not support for complex though...
920+
with pytest.raises(TypeError):
921+
op(sctype(3), 2**64)
922+
with pytest.raises(TypeError):
923+
op(sctype(3), 2**64)
924+
else:
925+
assert op(sctype(3), 2**64) == op(sctype(3), sctype(2**64))
926+
assert op(2**64, sctype(3)) == op(sctype(2**64), sctype(3))
926927

927928

928929
@pytest.mark.parametrize("dtype", np.typecodes["AllInteger"])

0 commit comments

Comments
 (0)
0