Skip to content

Commit 4907178

Browse files
committed
Dont catch OverflowError for single array funcs
1 parent eab08d9 commit 4907178

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

array_api_tests/test_type_promotion.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_func_returns_array_with_correct_dtype(
8181
x = data.draw(
8282
xps.arrays(dtype=in_dtypes[0], shape=hh.shapes).filter(x_filter), label='x'
8383
)
84-
arrays = [x]
84+
out = func(x)
8585
else:
8686
arrays = []
8787
shapes = data.draw(
@@ -92,10 +92,10 @@ def test_func_returns_array_with_correct_dtype(
9292
xps.arrays(dtype=dtype, shape=shape).filter(x_filter), label=f'x{i}'
9393
)
9494
arrays.append(x)
95-
try:
96-
out = func(*arrays)
97-
except OverflowError:
98-
reject()
95+
try:
96+
out = func(*arrays)
97+
except OverflowError:
98+
reject()
9999
assert out.dtype == out_dtype, f'{out.dtype=!s}, but should be {out_dtype}'
100100

101101

@@ -147,23 +147,24 @@ def gen_op_params() -> Iterator[Tuple[str, Tuple[DT, ...], DT, Callable]]:
147147
def test_operator_returns_array_with_correct_dtype(
148148
expr, in_dtypes, out_dtype, x_filter, data
149149
):
150-
locals_ = {}
151150
if len(in_dtypes) == 1:
152-
locals_['x'] = data.draw(
151+
x = data.draw(
153152
xps.arrays(dtype=in_dtypes[0], shape=hh.shapes).filter(x_filter), label='x'
154153
)
154+
out = eval(expr, {'x': x})
155155
else:
156+
locals_ = {}
156157
shapes = data.draw(
157158
hh.mutually_broadcastable_shapes(len(in_dtypes)), label='shapes'
158159
)
159160
for i, (dtype, shape) in enumerate(zip(in_dtypes, shapes), 1):
160161
locals_[f'x{i}'] = data.draw(
161162
xps.arrays(dtype=dtype, shape=shape).filter(x_filter), label=f'x{i}'
162163
)
163-
try:
164-
out = eval(expr, locals_)
165-
except OverflowError:
166-
reject()
164+
try:
165+
out = eval(expr, locals_)
166+
except OverflowError:
167+
reject()
167168
assert out.dtype == out_dtype, f'{out.dtype=!s}, but should be {out_dtype}'
168169

169170

0 commit comments

Comments
 (0)