File tree Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Original file line number Diff line number Diff line change 11from functools import wraps
22
33from hypothesis import strategies as st
4- from hypothesis .extra . array_api import make_strategies_namespace
4+ from hypothesis .extra import array_api
55
66from ._array_module import mod as _xp
77
88__all__ = ["xps" ]
99
10- xps = make_strategies_namespace (_xp )
11-
1210
1311# We monkey patch floats() to always disable subnormals as they are out-of-scope
1412
@@ -23,5 +21,29 @@ def floats(*a, **kw):
2321
2422st .floats = floats
2523
24+
25+ # We do the same with xps.from_dtype() - this is not strictly necessary, as
26+ # the underlying floats() will never generate subnormals. We only do this
27+ # because internal logic in xps.from_dtype() assumes xp.finfo() has its
28+ # attributes as scalar floats, which is expected behaviour but disrupts many
29+ # unrelated tests.
30+ try :
31+ __from_dtype = array_api ._from_dtype
32+
33+ @wraps (__from_dtype )
34+ def _from_dtype (* a , ** kw ):
35+ kw ["allow_subnormal" ] = False
36+ return __from_dtype (* a , ** kw )
37+
38+ array_api ._from_dtype = _from_dtype
39+ except AttributeError :
40+ # Ignore monkey patching if Hypothesis changes the private API
41+ pass
42+
43+
44+ xps = array_api .make_strategies_namespace (_xp )
45+
46+
2647from . import _version
27- __version__ = _version .get_versions ()['version' ]
48+
49+ __version__ = _version .get_versions ()["version" ]
You can’t perform that action at this time.
0 commit comments