Skip to content

Commit e38ce34

Browse files
authored
Merge pull request #252 from honno/patch-bool_
When `xp.bool` unavailable patch `xp.bool_` (underscore)
2 parents 6841d9c + b3a9ef4 commit e38ce34

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: array_api_tests/__init__.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
# You can comment the following out and instead import the specific array module
14-
# you want to test, e.g. `import numpy.array_api as xp`.
14+
# you want to test, e.g. `import array_api_strict as xp`.
1515
if "ARRAY_API_TESTS_MODULE" in os.environ:
1616
xp_name = os.environ["ARRAY_API_TESTS_MODULE"]
1717
_module, _sub = xp_name, None
@@ -33,6 +33,17 @@
3333
)
3434

3535

36+
# If xp.bool is not available, like in some versions of NumPy and CuPy, try
37+
# patching in xp.bool_.
38+
try:
39+
xp.bool
40+
except AttributeError as e:
41+
if hasattr(xp, "bool_"):
42+
xp.bool = xp.bool_
43+
else:
44+
raise e
45+
46+
3647
# We monkey patch floats() to always disable subnormals as they are out-of-scope
3748

3849
_floats = st.floats

0 commit comments

Comments
 (0)