Skip to content

Commit ad81cf6

Browse files
authored
Merge pull request #318 from jakevdp/silence-warning
Silence NonInteractiveExampleWarning in test_unary
2 parents d7bfe73 + 3689643 commit ad81cf6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

array_api_tests/test_special_cases.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
from decimal import ROUND_HALF_EVEN, Decimal
2121
from enum import Enum, auto
2222
from typing import Any, Callable, Dict, List, Optional, Protocol, Tuple, Literal
23-
from warnings import warn
23+
from warnings import warn, filterwarnings, catch_warnings
2424

2525
import pytest
2626
from hypothesis import given, note, settings, assume
2727
from hypothesis import strategies as st
28+
from hypothesis.errors import NonInteractiveExampleWarning
2829

2930
from array_api_tests.typing import Array, DataType
3031

@@ -1250,7 +1251,13 @@ def parse_binary_case_block(case_block: str, func_name: str) -> List[BinaryCase]
12501251

12511252
@pytest.mark.parametrize("func_name, func, case", unary_params)
12521253
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()
12541261
x = xp.asarray(in_value, dtype=xp.float64)
12551262
out = func(x)
12561263
out_value = float(out)

0 commit comments

Comments
 (0)