Skip to content

Commit 8b8ac96

Browse files
authored
Merge pull request #47 from honno/disable-subnormals
Monkey patch `st.floats()` to always disable subnormals
2 parents 6a92447 + f40e89d commit 8b8ac96

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

array_api_tests/__init__.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1+
from functools import wraps
2+
3+
from hypothesis import strategies as st
14
from hypothesis.extra.array_api import make_strategies_namespace
25

36
from ._array_module import mod as _xp
47

8+
__all__ = ["xps"]
59

610
xps = make_strategies_namespace(_xp)
711

812

9-
del _xp
10-
del make_strategies_namespace
13+
# We monkey patch floats() to always disable subnormals as they are out-of-scope
14+
15+
_floats = st.floats
16+
17+
18+
@wraps(_floats)
19+
def floats(*a, **kw):
20+
kw["allow_subnormal"] = False
21+
return _floats(*a, **kw)
22+
23+
24+
st.floats = floats

0 commit comments

Comments
 (0)