Skip to content

Fix array_namespace on numpy scalars #202

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

Merged
merged 1 commit into from
Nov 19, 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
6 changes: 3 additions & 3 deletions array_api_compat/common/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,7 @@ def your_function(x, y):

namespaces = set()
for x in xs:
if isinstance(x, (bool, int, float, complex, type(None))):
continue
elif is_numpy_array(x):
if is_numpy_array(x):
from .. import numpy as numpy_namespace
import numpy as np
if use_compat is True:
Expand Down Expand Up @@ -558,6 +556,8 @@ def your_function(x, y):
if use_compat is True:
raise ValueError("The given array does not have an array-api-compat wrapper")
namespaces.add(x.__array_namespace__(api_version=api_version))
elif isinstance(x, (bool, int, float, complex, type(None))):
continue
else:
# TODO: Support Python scalars?
raise TypeError(f"{type(x).__name__} is not a supported array type")
Expand Down
Loading