Skip to content

Commit

Permalink
Reinstate the guard against OverflowError for elementwise reference i…
Browse files Browse the repository at this point in the history
…mplementations

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.
  • Loading branch information
asmeurer committed Oct 18, 2024
1 parent aba096e commit 9fce298
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions array_api_tests/test_operators_and_elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ def unary_assert_against_refimpl(
scalar_i = in_stype(in_[idx])
if not filter_(scalar_i):
continue
expected = refimpl(scalar_i)
try:
expected = refimpl(scalar_i)
except OverflowError:
continue
if res.dtype != xp.bool:
if res.dtype in dh.complex_dtypes:
if expected.real <= m or expected.real >= M:
Expand Down Expand Up @@ -314,7 +317,10 @@ def binary_assert_against_refimpl(
scalar_r = in_stype(right[r_idx])
if not (filter_(scalar_l) and filter_(scalar_r)):
continue
expected = refimpl(scalar_l, scalar_r)
try:
expected = refimpl(scalar_l, scalar_r)
except OverflowError:
continue
if res.dtype != xp.bool:
if res.dtype in dh.complex_dtypes:
if expected.real <= m or expected.real >= M:
Expand Down Expand Up @@ -386,7 +392,10 @@ def right_scalar_assert_against_refimpl(
scalar_l = in_stype(left[idx])
if not (filter_(scalar_l) and filter_(right)):
continue
expected = refimpl(scalar_l, right)
try:
expected = refimpl(scalar_l, right)
except OverflowError:
continue
if left.dtype != xp.bool:
if res.dtype in dh.complex_dtypes:
if expected.real <= m or expected.real >= M:
Expand Down

0 comments on commit 9fce298

Please sign in to comment.