|
20 | 20 | from decimal import ROUND_HALF_EVEN, Decimal
|
21 | 21 | from enum import Enum, auto
|
22 | 22 | from typing import Any, Callable, Dict, List, Optional, Protocol, Tuple, Literal
|
23 |
| -from warnings import warn |
| 23 | +from warnings import warn, filterwarnings, catch_warnings |
24 | 24 |
|
25 | 25 | import pytest
|
26 | 26 | from hypothesis import given, note, settings, assume
|
27 | 27 | from hypothesis import strategies as st
|
| 28 | +from hypothesis.errors import NonInteractiveExampleWarning |
28 | 29 |
|
29 | 30 | from array_api_tests.typing import Array, DataType
|
30 | 31 |
|
@@ -1250,7 +1251,13 @@ def parse_binary_case_block(case_block: str, func_name: str) -> List[BinaryCase]
|
1250 | 1251 |
|
1251 | 1252 | @pytest.mark.parametrize("func_name, func, case", unary_params)
|
1252 | 1253 | def test_unary(func_name, func, case):
|
1253 |
| - in_value = case.cond_from_dtype(xp.float64).example() |
| 1254 | + with catch_warnings(): |
| 1255 | + # XXX: We are using example here to generate one example draw, but |
| 1256 | + # hypothesis issues a warning from this. We should consider either |
| 1257 | + # drawing multiple examples like a normal test, or just hard-coding a |
| 1258 | + # single example test case without using hypothesis. |
| 1259 | + filterwarnings('ignore', category=NonInteractiveExampleWarning) |
| 1260 | + in_value = case.cond_from_dtype(xp.float64).example() |
1254 | 1261 | x = xp.asarray(in_value, dtype=xp.float64)
|
1255 | 1262 | out = func(x)
|
1256 | 1263 | out_value = float(out)
|
|
0 commit comments