Skip to content

Commit 3499cf3

Browse files
committed
♻️ linalg: simplified _misc dtypes, and explicit Any dtypes
1 parent ccf6ae5 commit 3499cf3

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

scipy-stubs/linalg/_misc.pyi

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Literal, TypeAlias, TypeVar, overload
1+
from typing import Any, Literal, TypeAlias, TypeVar, overload
22

33
import numpy as np
44
import optype as op
@@ -11,8 +11,7 @@ __all__ = ["LinAlgError", "LinAlgWarning", "norm"]
1111
_Inf: TypeAlias = float
1212
_Order: TypeAlias = Literal["fro", "nuc", 0, 1, -1, 2, -2] | _Inf
1313
_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_
1615

1716
_ShapeT = TypeVar("_ShapeT", bound=tuple[int, ...])
1817

@@ -23,7 +22,7 @@ class LinAlgWarning(RuntimeWarning): ...
2322
# NOTE: the mypy errors are false positives (join vs union)
2423

2524
@overload # scalar, axis: None = ...
26-
def norm( # type: ignore[overload-overlap]
25+
def norm(
2726
a: complex | _SubScalar,
2827
ord: _Order | None = None,
2928
axis: None = None,
@@ -32,11 +31,7 @@ def norm( # type: ignore[overload-overlap]
3231
) -> np.float64: ...
3332
@overload # inexact32, axis: None = ...
3433
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
4035
) -> np.float32: ...
4136
@overload # longdouble, axis: None = ...
4237
def norm(
@@ -55,15 +50,15 @@ def norm(
5550
check_finite: onp.ToBool = True,
5651
) -> np.float64: ...
5752
@overload # float64-coercible array, keepdims: True (positional)
58-
def norm( # type: ignore[overload-overlap]
53+
def norm(
5954
a: onp.ArrayND[_SubScalar, _ShapeT],
6055
ord: _Order | None,
6156
axis: _Axis | None,
6257
keepdims: onp.ToTrue,
6358
check_finite: onp.ToBool = True,
6459
) -> onp.ArrayND[np.float64, _ShapeT]: ...
6560
@overload # float64-coercible array, keepdims: True (keyword)
66-
def norm( # type: ignore[overload-overlap]
61+
def norm(
6762
a: onp.ArrayND[_SubScalar, _ShapeT],
6863
ord: _Order | None = None,
6964
axis: _Axis | None = None,
@@ -72,15 +67,15 @@ def norm( # type: ignore[overload-overlap]
7267
check_finite: onp.ToBool = True,
7368
) -> onp.ArrayND[np.float64, _ShapeT]: ...
7469
@overload # float64-coercible array-like, keepdims: True (positional)
75-
def norm( # type: ignore[overload-overlap]
70+
def norm(
7671
a: onp.SequenceND[onp.CanArrayND[_SubScalar]] | onp.SequenceND[complex | _SubScalar],
7772
ord: _Order | None,
7873
axis: _Axis | None,
7974
keepdims: onp.ToTrue,
8075
check_finite: onp.ToBool = True,
8176
) -> onp.ArrayND[np.float64]: ...
8277
@overload # float64-coercible array-like, keepdims: True (keyword)
83-
def norm( # type: ignore[overload-overlap]
78+
def norm(
8479
a: onp.SequenceND[onp.CanArrayND[_SubScalar]] | onp.SequenceND[complex | _SubScalar],
8580
ord: _Order | None = None,
8681
axis: _Axis | None = None,
@@ -90,7 +85,7 @@ def norm( # type: ignore[overload-overlap]
9085
) -> onp.ArrayND[np.float64]: ...
9186
@overload # shaped inexact32 array, keepdims: True (positional)
9287
def norm(
93-
a: onp.ArrayND[np.float32 | np.complex64, _ShapeT],
88+
a: onp.ArrayND[npc.inexact32, _ShapeT],
9489
ord: _Order | None,
9590
axis: _Axis | None,
9691
keepdims: onp.ToTrue,
@@ -106,7 +101,7 @@ def norm(
106101
) -> onp.ArrayND[np.longdouble, _ShapeT]: ...
107102
@overload # shaped inexact32 array, keepdims: True (keyword)
108103
def norm(
109-
a: onp.ArrayND[np.float32 | np.complex64, _ShapeT],
104+
a: onp.ArrayND[npc.inexact32, _ShapeT],
110105
ord: _Order | None = None,
111106
axis: _Axis | None = None,
112107
*,
@@ -124,7 +119,7 @@ def norm(
124119
) -> onp.ArrayND[np.longdouble, _ShapeT]: ...
125120
@overload # scalar array-like, keepdims: True (positional)
126121
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],
128123
ord: _Order | None,
129124
axis: _Axis | None,
130125
keepdims: onp.ToTrue,
@@ -140,7 +135,7 @@ def norm(
140135
) -> onp.ArrayND[np.longdouble]: ...
141136
@overload # scalar array-like, keepdims: True (keyword)
142137
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],
144139
ord: _Order | None = None,
145140
axis: _Axis | None = None,
146141
*,
@@ -187,4 +182,4 @@ def norm(
187182
) -> npc.floating | onp.ArrayND[npc.floating]: ...
188183

189184
#
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

Comments
 (0)