Skip to content

Commit 9fce298

Browse files
committed
Reinstate the guard against OverflowError for elementwise reference implementations
Other exceptions should still be raised, but this is a common occurance which just means that the math library raises OverflowError in many instances instead of giving inf or nan.
1 parent aba096e commit 9fce298

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

array_api_tests/test_operators_and_elementwise_functions.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ def unary_assert_against_refimpl(
242242
scalar_i = in_stype(in_[idx])
243243
if not filter_(scalar_i):
244244
continue
245-
expected = refimpl(scalar_i)
245+
try:
246+
expected = refimpl(scalar_i)
247+
except OverflowError:
248+
continue
246249
if res.dtype != xp.bool:
247250
if res.dtype in dh.complex_dtypes:
248251
if expected.real <= m or expected.real >= M:
@@ -314,7 +317,10 @@ def binary_assert_against_refimpl(
314317
scalar_r = in_stype(right[r_idx])
315318
if not (filter_(scalar_l) and filter_(scalar_r)):
316319
continue
317-
expected = refimpl(scalar_l, scalar_r)
320+
try:
321+
expected = refimpl(scalar_l, scalar_r)
322+
except OverflowError:
323+
continue
318324
if res.dtype != xp.bool:
319325
if res.dtype in dh.complex_dtypes:
320326
if expected.real <= m or expected.real >= M:
@@ -386,7 +392,10 @@ def right_scalar_assert_against_refimpl(
386392
scalar_l = in_stype(left[idx])
387393
if not (filter_(scalar_l) and filter_(right)):
388394
continue
389-
expected = refimpl(scalar_l, right)
395+
try:
396+
expected = refimpl(scalar_l, right)
397+
except OverflowError:
398+
continue
390399
if left.dtype != xp.bool:
391400
if res.dtype in dh.complex_dtypes:
392401
if expected.real <= m or expected.real >= M:

0 commit comments

Comments
 (0)