Skip to content

Commit f40e89d

Browse files
committed
Monkey patch st.floats() to always disable subnormals
1 parent 6a92447 commit f40e89d

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)