Skip to content

BUG: fix issues with newaxis and linalg.solve in numpy.array_api #25146

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 14, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion numpy/array_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@

__all__ = ["__array_api_version__"]

from ._constants import e, inf, nan, pi
from ._constants import e, inf, nan, pi, newaxis

__all__ += ["e", "inf", "nan", "pi"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be added here as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make a PR?


Expand Down
1 change: 1 addition & 0 deletions numpy/array_api/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
inf = np.inf
nan = np.nan
pi = np.pi
newaxis = np.newaxis
6 changes: 3 additions & 3 deletions numpy/array_api/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ def _solve(a, b):
# This does nothing currently but is left in because it will be relevant
# when complex dtype support is added to the spec in 2022.
signature = 'DD->D' if isComplexType(t) else 'dd->d'
with errstate(call=_raise_linalgerror_singular, invalid='call',
over='ignore', divide='ignore', under='ignore'):
r = gufunc(a, b, signature=signature, extobj=extobj)
with np.errstate(call=_raise_linalgerror_singular, invalid='call',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that the errstate removal did make it? Anyay, LGTM, thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the implementation here was added before this was thoroughly tested in the test suite. Maybe the errstate import was removed and that went unnoticed due to incomplete test coverage.

over='ignore', divide='ignore', under='ignore'):
r = gufunc(a, b, signature=signature)

return wrap(r.astype(result_t, copy=False))

Expand Down