Skip to content

Commit dc4a066

Browse files
committed
Update test_assert_array_elements
Only assert mixed sign scenarios when signbit() is available
1 parent 5c1001c commit dc4a066

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

meta_tests/test_pytest_helpers.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from pytest import raises
22

3+
from array_api_tests import xp as _xp
34
from array_api_tests import _array_module as xp
45
from array_api_tests import pytest_helpers as ph
56

@@ -16,10 +17,12 @@ def test_assert_dtype():
1617
def test_assert_array_elements():
1718
ph.assert_array_elements("int zeros", out=xp.asarray(0), expected=xp.asarray(0))
1819
ph.assert_array_elements("pos zeros", out=xp.asarray(0.0), expected=xp.asarray(0.0))
19-
with raises(AssertionError):
20-
ph.assert_array_elements("mixed sign zeros", out=xp.asarray(0.0), expected=xp.asarray(-0.0))
21-
with raises(AssertionError):
22-
ph.assert_array_elements("mixed sign zeros", out=xp.asarray(-0.0), expected=xp.asarray(0.0))
20+
ph.assert_array_elements("neg zeros", out=xp.asarray(-0.0), expected=xp.asarray(-0.0))
21+
if hasattr(_xp, "signbit"):
22+
with raises(AssertionError):
23+
ph.assert_array_elements("mixed sign zeros", out=xp.asarray(0.0), expected=xp.asarray(-0.0))
24+
with raises(AssertionError):
25+
ph.assert_array_elements("mixed sign zeros", out=xp.asarray(-0.0), expected=xp.asarray(0.0))
2326

2427
ph.assert_array_elements("nans", out=xp.asarray(float("nan")), expected=xp.asarray(float("nan")))
2528
with raises(AssertionError):

0 commit comments

Comments
 (0)