12
12
import numpy .linalg
13
13
import numpy as np
14
14
15
- class eighresult (NamedTuple ):
15
+ class EIGHResult (NamedTuple ):
16
16
eigenvalues : Array
17
17
eigenvectors : Array
18
18
19
- class qrresult (NamedTuple ):
19
+ class QRResult (NamedTuple ):
20
20
q : Array
21
21
r : Array
22
22
23
- class slogdetresult (NamedTuple ):
23
+ class SLOGDETResult (NamedTuple ):
24
24
sign : Array
25
25
logabsdet : Array
26
26
27
- class svdresult (NamedTuple ):
27
+ class SVDResult (NamedTuple ):
28
28
u : Array
29
29
s : Array
30
30
vh : Array
@@ -86,7 +86,7 @@ def diagonal(x: Array, /, *, offset: int = 0) -> Array:
86
86
87
87
88
88
# Note: the keyword argument name upper is different from np.linalg.eigh
89
- def eigh (x : Array , / ) -> eighresult :
89
+ def eigh (x : Array , / ) -> EIGHResult :
90
90
"""
91
91
Array API compatible wrapper for :py:func:`np.eig <numpy.eigh>`.
92
92
@@ -99,7 +99,7 @@ def eigh(x: Array, /) -> eighresult:
99
99
100
100
# Note: the return type here is a namedtuple, which is different from
101
101
# np.eigh, which only returns a tuple.
102
- return eighresult (* map (Array ._new , np .linalg .eigh (x ._array )))
102
+ return EIGHResult (* map (Array ._new , np .linalg .eigh (x ._array )))
103
103
104
104
105
105
# Note: the keyword argument name upper is different from np.linalg.eigvalsh
@@ -240,7 +240,7 @@ def pinv(x: Array, /, *, rtol: Optional[Union[float, Array]] = None) -> Array:
240
240
rtol = max (x .shape [- 2 :]) * np .finfo (x .dtype ).eps
241
241
return Array ._new (np .linalg .pinv (x ._array , rcond = rtol ))
242
242
243
- def qr (x : Array , / , * , mode : Literal ['reduced' , 'complete' ] = 'reduced' ) -> Tuple [ Array , Array ] :
243
+ def qr (x : Array , / , * , mode : Literal ['reduced' , 'complete' ] = 'reduced' ) -> QRResult :
244
244
"""
245
245
Array API compatible wrapper for :py:func:`np.qr <numpy.qr>`.
246
246
@@ -256,9 +256,9 @@ def qr(x: Array, /, *, mode: Literal['reduced', 'complete'] = 'reduced') -> Tupl
256
256
257
257
# Note: the return type here is a namedtuple, which is different from
258
258
# np.linalg.qr, which only returns a tuple.
259
- return qrresult (* map (Array ._new , np .linalg .qr (x ._array , mode = mode )))
259
+ return QRResult (* map (Array ._new , np .linalg .qr (x ._array , mode = mode )))
260
260
261
- def slogdet (x : Array , / ) -> slogdetresult :
261
+ def slogdet (x : Array , / ) -> SLOGDETResult :
262
262
"""
263
263
Array API compatible wrapper for :py:func:`np.slogdet <numpy.slogdet>`.
264
264
@@ -271,7 +271,7 @@ def slogdet(x: Array, /) -> slogdetresult:
271
271
272
272
# Note: the return type here is a namedtuple, which is different from
273
273
# np.linalg.slogdet, which only returns a tuple.
274
- return slogdetresult (* map (Array ._new , np .linalg .slogdet (x ._array )))
274
+ return SLOGDETResult (* map (Array ._new , np .linalg .slogdet (x ._array )))
275
275
276
276
def solve (x1 : Array , x2 : Array , / ) -> Array :
277
277
"""
@@ -286,7 +286,7 @@ def solve(x1: Array, x2: Array, /) -> Array:
286
286
287
287
return Array ._new (np .linalg .solve (x1 ._array , x2 ._array ))
288
288
289
- def svd (x : Array , / , * , full_matrices : bool = True ) -> svdresult :
289
+ def svd (x : Array , / , * , full_matrices : bool = True ) -> SVDResult :
290
290
"""
291
291
Array API compatible wrapper for :py:func:`np.svd <numpy.svd>`.
292
292
@@ -299,7 +299,7 @@ def svd(x: Array, /, *, full_matrices: bool = True) -> svdresult:
299
299
300
300
# Note: the return type here is a namedtuple, which is different from
301
301
# np.svd, which only returns a tuple.
302
- return svdresult (* map (Array ._new , np .linalg .svd (x ._array , full_matrices = full_matrices )))
302
+ return SVDResult (* map (Array ._new , np .linalg .svd (x ._array , full_matrices = full_matrices )))
303
303
304
304
# Note: svdvals is not in NumPy (but it is in SciPy). It is equivalent to
305
305
# np.linalg.svd(compute_uv=False).
0 commit comments