Skip to content

Commit 10ba0b4

Browse files
authored
🩹 fix missing type arguments on numpy<2.3 (#779)
2 parents e58628f + 0d7bad4 commit 10ba0b4

File tree

11 files changed

+26
-22
lines changed

11 files changed

+26
-22
lines changed

‎scipy-stubs/_lib/_util.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def normalize_axis_index(axis: int | _AxisT, ndim: _AxisT) -> _AxisT: ...
126126
@overload
127127
def normalize_axis_index(axis: _AxisT, ndim: onp.NDim | _AxisT) -> _AxisT: ...
128128
@overload
129-
def np_vecdot(x1: onp.ToIntStrict1D, x2: onp.ToIntStrict1D, /, *, axis: op.CanIndex = -1) -> np.integer: ...
129+
def np_vecdot(x1: onp.ToIntStrict1D, x2: onp.ToIntStrict1D, /, *, axis: op.CanIndex = -1) -> npc.integer: ...
130130
@overload
131131
def np_vecdot(x1: onp.ToFloatStrict1D, x2: onp.ToJustFloatStrict1D, /, *, axis: op.CanIndex = -1) -> npc.floating: ...
132132
@overload

‎scipy-stubs/constants/_constants.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ __all__ = [
165165
"zetta",
166166
]
167167

168-
_InexactArrayLikeT = TypeVar("_InexactArrayLikeT", bound=npc.inexact | onp.ArrayND[np.inexact])
168+
_InexactArrayLikeT = TypeVar("_InexactArrayLikeT", bound=npc.inexact | onp.ArrayND[npc.inexact])
169169

170170
_TempScaleC: TypeAlias = Literal["Celsius", "celsius", "C", "c"]
171171
_TempScaleK: TypeAlias = Literal["Kelvin", "kelvin", "K", "k"]

‎scipy-stubs/fft/_realtransforms.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def idstn(
254254
#
255255
@overload
256256
def dct(
257-
x: onp.CanArrayND[np.integer, _ShapeT],
257+
x: onp.CanArrayND[npc.integer, _ShapeT],
258258
type: DCTType = 2,
259259
n: onp.ToInt | None = None,
260260
axis: op.CanIndex = -1,
@@ -311,7 +311,7 @@ def dct(
311311
#
312312
@overload
313313
def idct(
314-
x: onp.CanArrayND[np.integer, _ShapeT],
314+
x: onp.CanArrayND[npc.integer, _ShapeT],
315315
type: DCTType = 2,
316316
n: onp.ToInt | None = None,
317317
axis: op.CanIndex = -1,
@@ -368,7 +368,7 @@ def idct(
368368
#
369369
@overload
370370
def dst(
371-
x: onp.CanArrayND[np.integer, _ShapeT],
371+
x: onp.CanArrayND[npc.integer, _ShapeT],
372372
type: DCTType = 2,
373373
n: onp.ToInt | None = None,
374374
axis: op.CanIndex = -1,
@@ -425,7 +425,7 @@ def dst(
425425
#
426426
@overload
427427
def idst(
428-
x: onp.CanArrayND[np.integer, _ShapeT],
428+
x: onp.CanArrayND[npc.integer, _ShapeT],
429429
type: DCTType = 2,
430430
n: onp.ToInt | None = None,
431431
axis: op.CanIndex = -1,

‎scipy-stubs/integrate/_ivp/ivp.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ from scipy.sparse import sparray, spmatrix
1313
from scipy.sparse._base import _spbase
1414

1515
_Ts = TypeVarTuple("_Ts")
16-
_ScalarT = TypeVar("_ScalarT", bound=npc.number | np.bool)
16+
_ScalarT = TypeVar("_ScalarT", bound=npc.number | np.bool_)
1717
_Inexact64T = TypeVar("_Inexact64T", bound=np.float64 | np.complex128)
1818
_Inexact64T_co = TypeVar("_Inexact64T_co", bound=np.float64 | np.complex128, default=np.float64 | np.complex128, covariant=True)
1919

‎scipy-stubs/interpolate/_ndbspline.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ from typing_extensions import TypeVar
55
import numpy as np
66
import optype as op
77
import optype.numpy as onp
8+
import optype.numpy.compat as npc
89

910
from scipy.sparse import csr_array
1011

@@ -68,10 +69,10 @@ def make_ndbspl(
6869
values: onp.ToFloatND,
6970
k: _ToDegrees = 3,
7071
*,
71-
solver: _SolverFunc[np.floating | np.integer] = ..., # scipy.sparse.linalg.gcrotmk
72+
solver: _SolverFunc[npc.floating | npc.integer] = ..., # scipy.sparse.linalg.gcrotmk
7273
**solver_args: object,
7374
) -> NdBSpline[np.float64]: ...
7475
@overload
7576
def make_ndbspl(
76-
points: _ToKnots, values: onp.ToFloatND, k: _ToDegrees = 3, *, solver: _SolverFunc[np.complexfloating], **solver_args: object
77+
points: _ToKnots, values: onp.ToFloatND, k: _ToDegrees = 3, *, solver: _SolverFunc[npc.complexfloating], **solver_args: object
7778
) -> NdBSpline[np.complex128]: ...

‎scipy-stubs/interpolate/_rgi.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from typing_extensions import TypeVar
44

55
import numpy as np
66
import optype.numpy as onp
7+
import optype.numpy.compat as npc
78

89
from ._ndbspline import _SolverFunc
910

@@ -36,7 +37,7 @@ class RegularGridInterpolator(Generic[_CT_co]):
3637
bounds_error: onp.ToBool = True,
3738
fill_value: onp.ToFloat | None = ..., # np.nan
3839
*,
39-
solver: _SolverFunc[np.floating | np.integer] | None = None,
40+
solver: _SolverFunc[npc.floating | npc.integer] | None = None,
4041
solver_args: tuple[object, ...] | None = None,
4142
) -> None: ...
4243
@overload
@@ -49,7 +50,7 @@ class RegularGridInterpolator(Generic[_CT_co]):
4950
bounds_error: onp.ToBool = True,
5051
fill_value: onp.ToComplex | None = ..., # np.nan
5152
*,
52-
solver: _SolverFunc[np.number] | None = None,
53+
solver: _SolverFunc[npc.number] | None = None,
5354
solver_args: tuple[object, ...] | None = None,
5455
) -> None: ...
5556
@overload
@@ -62,7 +63,7 @@ class RegularGridInterpolator(Generic[_CT_co]):
6263
bounds_error: onp.ToBool = True,
6364
fill_value: onp.ToComplex | None = ..., # np.nan
6465
*,
65-
solver: _SolverFunc[np.number] | None = None,
66+
solver: _SolverFunc[npc.number] | None = None,
6667
solver_args: tuple[object, ...] | None = None,
6768
) -> None: ...
6869

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# NOTE: keep in sync with scipy/stubs/linalg/_decomp_lu_cython.pyi
22

3-
from typing import TypeVar
3+
from typing import Any, TypeVar
44

55
import numpy as np
66
import numpy.typing as npt
77

88
# this mimicks the `ctypedef fused lapack_t`
99
_LapackT = TypeVar("_LapackT", np.float32, np.float64, np.complex64, np.complex128)
1010

11-
def lu_dispatcher(a: npt.NDArray[_LapackT], u: npt.NDArray[_LapackT], piv: npt.NDArray[np.integer], permute_l: bool) -> None: ...
11+
def lu_dispatcher(
12+
a: npt.NDArray[_LapackT], u: npt.NDArray[_LapackT], piv: npt.NDArray[np.integer[Any]], permute_l: bool
13+
) -> None: ...

‎scipy-stubs/linalg/_testutils.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class _FakeMatrix(Generic[_ScalarT, _ShapeT]): # undocumented
1919
class _FakeMatrix2(Generic[_ScalarT, _ShapeT]): # undocumented
2020
_data: onp.ArrayND[_ScalarT, _ShapeT]
2121
def __init__(self, /, data: onp.ArrayND[_ScalarT, _ShapeT]) -> None: ...
22-
def __array__(self, /, dtype: np.dtype | None = None, copy: bool | None = None) -> onp.ArrayND[_ScalarT, _ShapeT]: ...
22+
def __array__(self, /, dtype: np.dtype[Any] | None = None, copy: bool | None = None) -> onp.ArrayND[_ScalarT, _ShapeT]: ...
2323

2424
def _get_array(shape: _ShapeT, dtype: type[_ScalarT]) -> onp.ArrayND[_ScalarT, _ShapeT]: ... # undocumented
2525
def _id(x: _T) -> _T: ... # undocumented

‎scipy-stubs/sparse/linalg/_isolve/lsmr.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ from scipy.sparse.linalg import LinearOperator
99

1010
__all__ = ["lsmr"]
1111

12-
_Real: TypeAlias = np.bool_ | npc.integer | np.floating
12+
_Real: TypeAlias = np.bool_ | npc.integer | npc.floating
1313
_ToRealMatrix: TypeAlias = onp.CanArrayND[_Real] | _spbase[_Real] | LinearOperator[_Real]
1414

1515
_IStop: TypeAlias = Literal[0, 1, 2, 3, 4, 5, 6, 7]

‎scipy-stubs/sparse/linalg/_isolve/lsqr.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ from scipy.sparse.linalg import LinearOperator
99

1010
__all__ = ["lsqr"]
1111

12-
_Real: TypeAlias = np.bool_ | npc.integer | np.floating
12+
_Real: TypeAlias = np.bool_ | npc.integer | npc.floating
1313
_ToRealMatrix: TypeAlias = onp.CanArrayND[_Real] | _spbase[_Real] | LinearOperator[_Real]
1414

1515
_IStop: TypeAlias = Literal[0, 1, 2, 3, 4, 5, 6, 7]

0 commit comments

Comments
 (0)