|
4 | 4 |
|
5 | 5 | from hypothesis import assume, given |
6 | 6 | from hypothesis import strategies as st |
| 7 | +from hypothesis.control import reject |
7 | 8 |
|
8 | 9 | from . import _array_module as xp |
9 | 10 | from . import array_helpers as ah |
@@ -202,7 +203,10 @@ def test_prod(x, data): |
202 | 203 | label="kw", |
203 | 204 | ) |
204 | 205 |
|
205 | | - out = xp.prod(x, **kw) |
| 206 | + try: |
| 207 | + out = xp.prod(x, **kw) |
| 208 | + except OverflowError: |
| 209 | + reject() |
206 | 210 |
|
207 | 211 | dtype = kw.get("dtype", None) |
208 | 212 | if dtype is None: |
@@ -232,7 +236,7 @@ def test_prod(x, data): |
232 | 236 | scalar_type = dh.get_scalar_type(out.dtype) |
233 | 237 | for indices, out_idx in zip(axes_ndindex(x.shape, _axes), ah.ndindex(out.shape)): |
234 | 238 | prod = scalar_type(out[out_idx]) |
235 | | - assume(not math.isinf(prod)) |
| 239 | + assume(math.isfinite(prod)) |
236 | 240 | elements = [] |
237 | 241 | for idx in indices: |
238 | 242 | s = scalar_type(x[idx]) |
@@ -297,7 +301,10 @@ def test_sum(x, data): |
297 | 301 | label="kw", |
298 | 302 | ) |
299 | 303 |
|
300 | | - out = xp.sum(x, **kw) |
| 304 | + try: |
| 305 | + out = xp.sum(x, **kw) |
| 306 | + except OverflowError: |
| 307 | + reject() |
301 | 308 |
|
302 | 309 | dtype = kw.get("dtype", None) |
303 | 310 | if dtype is None: |
@@ -327,7 +334,7 @@ def test_sum(x, data): |
327 | 334 | scalar_type = dh.get_scalar_type(out.dtype) |
328 | 335 | for indices, out_idx in zip(axes_ndindex(x.shape, _axes), ah.ndindex(out.shape)): |
329 | 336 | sum_ = scalar_type(out[out_idx]) |
330 | | - assume(not math.isinf(sum_)) |
| 337 | + assume(math.isfinite(sum_)) |
331 | 338 | elements = [] |
332 | 339 | for idx in indices: |
333 | 340 | s = scalar_type(x[idx]) |
|
0 commit comments