From 562d55fe7b6b6e03d7fd776392f56fb992a2bafd Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Tue, 14 Nov 2023 13:08:41 +0100 Subject: [PATCH] BUG: fix issues with `newaxis` and `linalg.solve` in `numpy.array_api` [skip azp] [skip cirrus] [skip circle] --- numpy/array_api/__init__.py | 2 +- numpy/array_api/_constants.py | 1 + numpy/array_api/linalg.py | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/numpy/array_api/__init__.py b/numpy/array_api/__init__.py index 964873faab20..77f227882e3e 100644 --- a/numpy/array_api/__init__.py +++ b/numpy/array_api/__init__.py @@ -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"] diff --git a/numpy/array_api/_constants.py b/numpy/array_api/_constants.py index 9541941e7c6f..15ab81d16d93 100644 --- a/numpy/array_api/_constants.py +++ b/numpy/array_api/_constants.py @@ -4,3 +4,4 @@ inf = np.inf nan = np.nan pi = np.pi +newaxis = np.newaxis diff --git a/numpy/array_api/linalg.py b/numpy/array_api/linalg.py index e8011aca6c5c..67a66bc185e6 100644 --- a/numpy/array_api/linalg.py +++ b/numpy/array_api/linalg.py @@ -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', + over='ignore', divide='ignore', under='ignore'): + r = gufunc(a, b, signature=signature) return wrap(r.astype(result_t, copy=False))