Skip to content

Commit 61c5aa0

Browse files
committed
Use ndarrays for abs and some inverse trig tests
1 parent b635fff commit 61c5aa0

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

array_api_tests/test_elementwise_functions.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def sanity_check(x1, x2):
6969
except ValueError:
7070
raise RuntimeError("Error in test generation (probably a bug in the test suite")
7171

72-
@given(numeric_scalars)
72+
@given(xps.arrays(dtype=xps.numeric_dtypes(), shape=shapes))
7373
def test_abs(x):
7474
if is_integer_dtype(x.dtype):
7575
minval = dtype_ranges[x.dtype][0]
@@ -86,7 +86,7 @@ def test_abs(x):
8686
# abs(x) = x for x >= 0
8787
assert_exactly_equal(a[logical_not(less_zero)], x[logical_not(less_zero)])
8888

89-
@given(floating_scalars)
89+
@given(xps.arrays(dtype=xps.floating_dtypes(), shape=shapes))
9090
def test_acos(x):
9191
a = xp.acos(x)
9292
ONE = one(x.shape, x.dtype)
@@ -100,7 +100,7 @@ def test_acos(x):
100100
# nan, which is already tested in the special cases.
101101
assert_exactly_equal(domain, codomain)
102102

103-
@given(floating_scalars)
103+
@given(xps.arrays(dtype=xps.floating_dtypes(), shape=shapes))
104104
def test_acosh(x):
105105
a = xp.acosh(x)
106106
ONE = one(x.shape, x.dtype)
@@ -112,9 +112,9 @@ def test_acosh(x):
112112
# to nan, which is already tested in the special cases.
113113
assert_exactly_equal(domain, codomain)
114114

115-
@given(two_numeric_dtypes.flatmap(lambda i: two_array_scalars(*i)))
116-
def test_add(args):
117-
x1, x2 = args
115+
@given(two_mutual_arrays(numeric_dtype_objects))
116+
def test_add(x1_and_x2):
117+
x1, x2 = x1_and_x2
118118
sanity_check(x1, x2)
119119
a = xp.add(x1, x2)
120120

@@ -123,7 +123,7 @@ def test_add(args):
123123
assert_exactly_equal(a, b)
124124
# TODO: Test that add is actually addition
125125

126-
@given(floating_scalars)
126+
@given(xps.arrays(dtype=xps.floating_dtypes(), shape=shapes))
127127
def test_asin(x):
128128
a = xp.asin(x)
129129
ONE = one(x.shape, x.dtype)
@@ -134,7 +134,7 @@ def test_asin(x):
134134
# mapped to nan, which is already tested in the special cases.
135135
assert_exactly_equal(domain, codomain)
136136

137-
@given(floating_scalars)
137+
@given(xps.arrays(dtype=xps.floating_dtypes(), shape=shapes))
138138
def test_asinh(x):
139139
a = xp.asinh(x)
140140
INFINITY = infinity(x.shape, x.dtype)
@@ -144,7 +144,7 @@ def test_asinh(x):
144144
# mapped to nan, which is already tested in the special cases.
145145
assert_exactly_equal(domain, codomain)
146146

147-
@given(floating_scalars)
147+
@given(xps.arrays(dtype=xps.floating_dtypes(), shape=shapes))
148148
def test_atan(x):
149149
a = xp.atan(x)
150150
INFINITY = infinity(x.shape, x.dtype)
@@ -155,9 +155,9 @@ def test_atan(x):
155155
# mapped to nan, which is already tested in the special cases.
156156
assert_exactly_equal(domain, codomain)
157157

158-
@given(two_floating_dtypes.flatmap(lambda i: two_array_scalars(*i)))
159-
def test_atan2(args):
160-
x1, x2 = args
158+
@given(two_mutual_arrays(floating_dtype_objects))
159+
def test_atan2(x1_and_x2):
160+
x1, x2 = x1_and_x2
161161
sanity_check(x1, x2)
162162
a = xp.atan2(x1, x2)
163163
INFINITY1 = infinity(x1.shape, x1.dtype)
@@ -192,7 +192,7 @@ def test_atan2(args):
192192
assert_exactly_equal(logical_or(logical_and(negx1, posx2),
193193
logical_and(negx1, negx2)), nega)
194194

195-
@given(floating_scalars)
195+
@given(xps.arrays(dtype=xps.floating_dtypes(), shape=shapes))
196196
def test_atanh(x):
197197
a = xp.atanh(x)
198198
ONE = one(x.shape, x.dtype)

0 commit comments

Comments
 (0)