Skip to content

Commit

Permalink
Fallback to xp.bool_
Browse files Browse the repository at this point in the history
  • Loading branch information
honno committed Apr 11, 2024
1 parent 3cf8ef6 commit b3a9ef4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion array_api_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


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


# If xp.bool is not available, like in some versions of NumPy and CuPy, try
# patching in xp.bool_.
try:
xp.bool
except AttributeError as e:
if hasattr(xp, "bool_"):
xp.bool = xp.bool_
else:
raise e


# We monkey patch floats() to always disable subnormals as they are out-of-scope

_floats = st.floats
Expand Down

0 comments on commit b3a9ef4

Please sign in to comment.