Skip to content

Commit 5b0c49a

Browse files
committed
Use finite mask for test_trunc
1 parent f7838d3 commit 5b0c49a

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

array_api_tests/test_elementwise_functions.py

+3-13
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
spec does not make any accuracy requirements for functions, so this does not
88
test that. Tests for the special cases are generated and tested separately in
99
special_cases/
10-
11-
Note: Due to current limitations in Hypothesis, the tests below only test
12-
arrays of shape (). In the future, the tests should be updated to test
13-
arrays of any shape, using masking patterns (similar to the tests in special_cases/
14-
1510
"""
1611

1712
import math
@@ -913,18 +908,13 @@ def test_tanh(x):
913908
# a = xp.tanh(x)
914909
pass
915910

916-
@given(
917-
xps.arrays(
918-
dtype=hh.numeric_dtypes,
919-
shape=xps.array_shapes(),
920-
elements={"allow_nan": False, "allow_infinity": False},
921-
)
922-
)
911+
@given(xps.arrays(dtype=hh.numeric_dtypes, shape=xps.array_shapes()))
923912
def test_trunc(x):
924913
out = xp.trunc(x)
925914
assert out.dtype == x.dtype, f"{x.dtype=!s} but {out.dtype=!s}"
926915
assert out.shape == x.shape, f"{x.shape=} but {out.shape=}"
927916
if x.dtype in hh.integer_dtype_objects:
928917
assert ah.all(ah.equal(x, out)), f"{x=!s} but {out=!s}"
929918
else:
930-
ah.assert_integral(out)
919+
finite = ah.isfinite(x)
920+
ah.assert_integral(out[finite])

0 commit comments

Comments
 (0)