1
- from typing import Literal , TypeAlias , TypeVar , overload
1
+ from typing import Any , Literal , TypeAlias , TypeVar , overload
2
2
3
3
import numpy as np
4
4
import optype as op
@@ -11,8 +11,7 @@ __all__ = ["LinAlgError", "LinAlgWarning", "norm"]
11
11
_Inf : TypeAlias = float
12
12
_Order : TypeAlias = Literal ["fro" , "nuc" , 0 , 1 , - 1 , 2 , - 2 ] | _Inf
13
13
_Axis : TypeAlias = op .CanIndex | tuple [op .CanIndex , op .CanIndex ]
14
-
15
- _SubScalar : TypeAlias = np .complex128 | np .float64 | npc .integer | np .bool_
14
+ _SubScalar : TypeAlias = npc .inexact64 | npc .integer | np .bool_
16
15
17
16
_ShapeT = TypeVar ("_ShapeT" , bound = tuple [int , ...])
18
17
@@ -23,7 +22,7 @@ class LinAlgWarning(RuntimeWarning): ...
23
22
# NOTE: the mypy errors are false positives (join vs union)
24
23
25
24
@overload # scalar, axis: None = ...
26
- def norm ( # type: ignore[overload-overlap]
25
+ def norm (
27
26
a : complex | _SubScalar ,
28
27
ord : _Order | None = None ,
29
28
axis : None = None ,
@@ -32,11 +31,7 @@ def norm( # type: ignore[overload-overlap]
32
31
) -> np .float64 : ...
33
32
@overload # inexact32, axis: None = ...
34
33
def norm (
35
- a : np .float32 | np .complex64 ,
36
- ord : _Order | None = None ,
37
- axis : None = None ,
38
- keepdims : op .CanBool = False ,
39
- check_finite : onp .ToBool = True ,
34
+ a : npc .inexact32 , ord : _Order | None = None , axis : None = None , keepdims : op .CanBool = False , check_finite : onp .ToBool = True
40
35
) -> np .float32 : ...
41
36
@overload # longdouble, axis: None = ...
42
37
def norm (
@@ -55,15 +50,15 @@ def norm(
55
50
check_finite : onp .ToBool = True ,
56
51
) -> np .float64 : ...
57
52
@overload # float64-coercible array, keepdims: True (positional)
58
- def norm ( # type: ignore[overload-overlap]
53
+ def norm (
59
54
a : onp .ArrayND [_SubScalar , _ShapeT ],
60
55
ord : _Order | None ,
61
56
axis : _Axis | None ,
62
57
keepdims : onp .ToTrue ,
63
58
check_finite : onp .ToBool = True ,
64
59
) -> onp .ArrayND [np .float64 , _ShapeT ]: ...
65
60
@overload # float64-coercible array, keepdims: True (keyword)
66
- def norm ( # type: ignore[overload-overlap]
61
+ def norm (
67
62
a : onp .ArrayND [_SubScalar , _ShapeT ],
68
63
ord : _Order | None = None ,
69
64
axis : _Axis | None = None ,
@@ -72,15 +67,15 @@ def norm( # type: ignore[overload-overlap]
72
67
check_finite : onp .ToBool = True ,
73
68
) -> onp .ArrayND [np .float64 , _ShapeT ]: ...
74
69
@overload # float64-coercible array-like, keepdims: True (positional)
75
- def norm ( # type: ignore[overload-overlap]
70
+ def norm (
76
71
a : onp .SequenceND [onp .CanArrayND [_SubScalar ]] | onp .SequenceND [complex | _SubScalar ],
77
72
ord : _Order | None ,
78
73
axis : _Axis | None ,
79
74
keepdims : onp .ToTrue ,
80
75
check_finite : onp .ToBool = True ,
81
76
) -> onp .ArrayND [np .float64 ]: ...
82
77
@overload # float64-coercible array-like, keepdims: True (keyword)
83
- def norm ( # type: ignore[overload-overlap]
78
+ def norm (
84
79
a : onp .SequenceND [onp .CanArrayND [_SubScalar ]] | onp .SequenceND [complex | _SubScalar ],
85
80
ord : _Order | None = None ,
86
81
axis : _Axis | None = None ,
@@ -90,7 +85,7 @@ def norm( # type: ignore[overload-overlap]
90
85
) -> onp .ArrayND [np .float64 ]: ...
91
86
@overload # shaped inexact32 array, keepdims: True (positional)
92
87
def norm (
93
- a : onp .ArrayND [np . float32 | np . complex64 , _ShapeT ],
88
+ a : onp .ArrayND [npc . inexact32 , _ShapeT ],
94
89
ord : _Order | None ,
95
90
axis : _Axis | None ,
96
91
keepdims : onp .ToTrue ,
@@ -106,7 +101,7 @@ def norm(
106
101
) -> onp .ArrayND [np .longdouble , _ShapeT ]: ...
107
102
@overload # shaped inexact32 array, keepdims: True (keyword)
108
103
def norm (
109
- a : onp .ArrayND [np . float32 | np . complex64 , _ShapeT ],
104
+ a : onp .ArrayND [npc . inexact32 , _ShapeT ],
110
105
ord : _Order | None = None ,
111
106
axis : _Axis | None = None ,
112
107
* ,
@@ -124,7 +119,7 @@ def norm(
124
119
) -> onp .ArrayND [np .longdouble , _ShapeT ]: ...
125
120
@overload # scalar array-like, keepdims: True (positional)
126
121
def norm (
127
- a : onp .SequenceND [onp .CanArrayND [np . float32 | np . complex64 ]] | onp .SequenceND [np . float32 | np . complex64 ],
122
+ a : onp .SequenceND [onp .CanArrayND [npc . inexact32 ]] | onp .SequenceND [npc . inexact32 ],
128
123
ord : _Order | None ,
129
124
axis : _Axis | None ,
130
125
keepdims : onp .ToTrue ,
@@ -140,7 +135,7 @@ def norm(
140
135
) -> onp .ArrayND [np .longdouble ]: ...
141
136
@overload # scalar array-like, keepdims: True (keyword)
142
137
def norm (
143
- a : onp .SequenceND [onp .CanArrayND [np . float32 | np . complex64 ]] | onp .SequenceND [np . float32 | np . complex64 ],
138
+ a : onp .SequenceND [onp .CanArrayND [npc . inexact32 ]] | onp .SequenceND [npc . inexact32 ],
144
139
ord : _Order | None = None ,
145
140
axis : _Axis | None = None ,
146
141
* ,
@@ -187,4 +182,4 @@ def norm(
187
182
) -> npc .floating | onp .ArrayND [npc .floating ]: ...
188
183
189
184
#
190
- def _datacopied (arr : onp .ArrayND , original : onp .CanArrayND ) -> bool : ... # undocumented
185
+ def _datacopied (arr : onp .ArrayND [ Any ] , original : onp .CanArrayND [ Any ] ) -> bool : ... # undocumented
0 commit comments