Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When xp.bool unavailable patch xp.bool_ (underscore) #252

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading