Skip to content

Commit 5b9842f

Browse files
committed
🎨 replace npt.NDArray with _nt.Array in np._core
1 parent 1918655 commit 5b9842f

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

‎src/numpy-stubs/_core/_internal.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import ctypes as ct
22
import re
33
from collections.abc import Callable, Iterable
4-
from typing import Any, Final, Generic, Self, overload
4+
from typing import Final, Generic, Self, overload
55
from typing_extensions import TypeVar, deprecated, override
66

7+
import _numtype as _nt
78
import numpy as np
8-
import numpy.typing as npt
99
from numpy.ctypeslib import c_intp
1010

1111
###
@@ -30,9 +30,9 @@ space_re: Final[re.Pattern[str]] = ...
3030

3131
class _ctypes(Generic[_PT_co]):
3232
@overload
33-
def __init__(self: _ctypes[None], /, array: npt.NDArray[Any], ptr: None = None) -> None: ...
33+
def __init__(self: _ctypes[None], /, array: _nt.Array, ptr: None = None) -> None: ...
3434
@overload
35-
def __init__(self, /, array: npt.NDArray[Any], ptr: _PT_co) -> None: ...
35+
def __init__(self, /, array: _nt.Array, ptr: _PT_co) -> None: ...
3636

3737
#
3838
@property

‎src/numpy-stubs/_core/_multiarray_umath.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,7 @@ def datetime_as_string(
18231823
) -> np.str_: ...
18241824
@overload
18251825
def datetime_as_string(
1826-
arr: npt.NDArray[np.datetime64],
1826+
arr: _nt.Array[np.datetime64],
18271827
unit: L["auto"] | _TimeUnit | None = None,
18281828
timezone: _TimeZone = "naive",
18291829
casting: _CastingKind = "same_kind",

‎src/numpy-stubs/_core/shape_base.pyi

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

55
import _numtype as _nt
66
import numpy as np
7-
from numpy._typing import ArrayLike, DTypeLike, NDArray, _ArrayLike, _DTypeLike
7+
from numpy._typing import ArrayLike, DTypeLike, _ArrayLike, _DTypeLike
88

99
__all__ = ["atleast_1d", "atleast_2d", "atleast_3d", "block", "hstack", "stack", "unstack", "vstack"]
1010

@@ -14,7 +14,7 @@ _ScalarT = TypeVar("_ScalarT", bound=np.generic)
1414
_SCT0 = TypeVar("_SCT0", bound=np.generic)
1515
_SCT1 = TypeVar("_SCT1", bound=np.generic)
1616

17-
_ArrayT = TypeVar("_ArrayT", bound=NDArray[Any])
17+
_ArrayT = TypeVar("_ArrayT", bound=_nt.Array[Any])
1818

1919
_Array1T = TypeVar("_Array1T", bound=np.ndarray[_nt.Shape1N, np.dtype])
2020
_Array1T0 = TypeVar("_Array1T0", bound=np.ndarray[_nt.Shape1N, np.dtype])
@@ -38,19 +38,19 @@ def atleast_1d(a0: _Array1T0, a1: _Array1T1, /) -> tuple[_Array1T0, _Array1T1]:
3838
@overload
3939
def atleast_1d(a0: _Array1T, a1: _Array1T, /, *arys: _Array1T) -> tuple[_Array1T, ...]: ... # type: ignore[overload-overlap]
4040
@overload
41-
def atleast_1d(a0: _ArrayLike[_ScalarT], /) -> NDArray[_ScalarT]: ...
41+
def atleast_1d(a0: _ArrayLike[_ScalarT], /) -> _nt.Array[_ScalarT]: ...
4242
@overload
43-
def atleast_1d(a0: _ArrayLike[_SCT0], a2: _ArrayLike[_SCT1], /) -> tuple[NDArray[_SCT0], NDArray[_SCT1]]: ...
43+
def atleast_1d(a0: _ArrayLike[_SCT0], a2: _ArrayLike[_SCT1], /) -> tuple[_nt.Array[_SCT0], _nt.Array[_SCT1]]: ...
4444
@overload
4545
def atleast_1d(
4646
a0: _ArrayLike[_ScalarT], a2: _ArrayLike[_ScalarT], /, *arys: _ArrayLike[_ScalarT]
47-
) -> tuple[NDArray[_ScalarT], ...]: ...
47+
) -> tuple[_nt.Array[_ScalarT], ...]: ...
4848
@overload
49-
def atleast_1d(a0: ArrayLike, /) -> NDArray[Any]: ...
49+
def atleast_1d(a0: ArrayLike, /) -> _nt.Array[Any]: ...
5050
@overload
51-
def atleast_1d(a0: ArrayLike, a2: ArrayLike, /) -> tuple[NDArray[Any], NDArray[Any]]: ...
51+
def atleast_1d(a0: ArrayLike, a2: ArrayLike, /) -> tuple[_nt.Array[Any], _nt.Array[Any]]: ...
5252
@overload
53-
def atleast_1d(a0: ArrayLike, a2: ArrayLike, /, *arys: ArrayLike) -> tuple[NDArray[Any], ...]: ...
53+
def atleast_1d(a0: ArrayLike, a2: ArrayLike, /, *arys: ArrayLike) -> tuple[_nt.Array[Any], ...]: ...
5454

5555
#
5656
@overload
@@ -60,19 +60,19 @@ def atleast_2d(a0: _Array2T0, a1: _Array2T1, /) -> tuple[_Array2T0, _Array2T1]:
6060
@overload
6161
def atleast_2d(a0: _Array2T, a1: _Array2T, /, *arys: _Array2T) -> tuple[_Array2T, ...]: ... # type: ignore[overload-overlap]
6262
@overload
63-
def atleast_2d(a0: _ArrayLike[_ScalarT], /) -> NDArray[_ScalarT]: ...
63+
def atleast_2d(a0: _ArrayLike[_ScalarT], /) -> _nt.Array[_ScalarT]: ...
6464
@overload
65-
def atleast_2d(a0: _ArrayLike[_SCT0], a2: _ArrayLike[_SCT1], /) -> tuple[NDArray[_SCT0], NDArray[_SCT1]]: ...
65+
def atleast_2d(a0: _ArrayLike[_SCT0], a2: _ArrayLike[_SCT1], /) -> tuple[_nt.Array[_SCT0], _nt.Array[_SCT1]]: ...
6666
@overload
6767
def atleast_2d(
6868
a0: _ArrayLike[_ScalarT], a2: _ArrayLike[_ScalarT], /, *arys: _ArrayLike[_ScalarT]
69-
) -> tuple[NDArray[_ScalarT], ...]: ...
69+
) -> tuple[_nt.Array[_ScalarT], ...]: ...
7070
@overload
71-
def atleast_2d(a0: ArrayLike, /) -> NDArray[Any]: ...
71+
def atleast_2d(a0: ArrayLike, /) -> _nt.Array[Any]: ...
7272
@overload
73-
def atleast_2d(a0: ArrayLike, a2: ArrayLike, /) -> tuple[NDArray[Any], NDArray[Any]]: ...
73+
def atleast_2d(a0: ArrayLike, a2: ArrayLike, /) -> tuple[_nt.Array[Any], _nt.Array[Any]]: ...
7474
@overload
75-
def atleast_2d(a0: ArrayLike, a2: ArrayLike, /, *arys: ArrayLike) -> tuple[NDArray[Any], ...]: ...
75+
def atleast_2d(a0: ArrayLike, a2: ArrayLike, /, *arys: ArrayLike) -> tuple[_nt.Array[Any], ...]: ...
7676

7777
#
7878
@overload
@@ -82,19 +82,19 @@ def atleast_3d(a0: _Array3T0, a1: _Array3T1, /) -> tuple[_Array3T0, _Array3T1]:
8282
@overload
8383
def atleast_3d(a0: _Array3T, a1: _Array3T, /, *arys: _Array3T) -> tuple[_Array3T, ...]: ... # type: ignore[overload-overlap]
8484
@overload
85-
def atleast_3d(a0: _ArrayLike[_ScalarT], /) -> NDArray[_ScalarT]: ...
85+
def atleast_3d(a0: _ArrayLike[_ScalarT], /) -> _nt.Array[_ScalarT]: ...
8686
@overload
87-
def atleast_3d(a0: _ArrayLike[_SCT0], a2: _ArrayLike[_SCT1], /) -> tuple[NDArray[_SCT0], NDArray[_SCT1]]: ...
87+
def atleast_3d(a0: _ArrayLike[_SCT0], a2: _ArrayLike[_SCT1], /) -> tuple[_nt.Array[_SCT0], _nt.Array[_SCT1]]: ...
8888
@overload
8989
def atleast_3d(
9090
a0: _ArrayLike[_ScalarT], a2: _ArrayLike[_ScalarT], /, *arys: _ArrayLike[_ScalarT]
91-
) -> tuple[NDArray[_ScalarT], ...]: ...
91+
) -> tuple[_nt.Array[_ScalarT], ...]: ...
9292
@overload
93-
def atleast_3d(a0: ArrayLike, /) -> NDArray[Any]: ...
93+
def atleast_3d(a0: ArrayLike, /) -> _nt.Array[Any]: ...
9494
@overload
95-
def atleast_3d(a0: ArrayLike, a2: ArrayLike, /) -> tuple[NDArray[Any], NDArray[Any]]: ...
95+
def atleast_3d(a0: ArrayLike, a2: ArrayLike, /) -> tuple[_nt.Array[Any], _nt.Array[Any]]: ...
9696
@overload
97-
def atleast_3d(a0: ArrayLike, a2: ArrayLike, /, *arys: ArrayLike) -> tuple[NDArray[Any], ...]: ...
97+
def atleast_3d(a0: ArrayLike, a2: ArrayLike, /, *arys: ArrayLike) -> tuple[_nt.Array[Any], ...]: ...
9898

9999
#
100100
@overload
@@ -103,21 +103,21 @@ def vstack(
103103
*,
104104
dtype: None = None,
105105
casting: np._CastingKind = "same_kind",
106-
) -> NDArray[_ScalarT]: ...
106+
) -> _nt.Array[_ScalarT]: ...
107107
@overload
108108
def vstack(
109109
tup: Sequence[ArrayLike],
110110
*,
111111
dtype: _DTypeLike[_ScalarT],
112112
casting: np._CastingKind = "same_kind",
113-
) -> NDArray[_ScalarT]: ...
113+
) -> _nt.Array[_ScalarT]: ...
114114
@overload
115115
def vstack(
116116
tup: Sequence[ArrayLike],
117117
*,
118118
dtype: DTypeLike | None = None,
119119
casting: np._CastingKind = "same_kind",
120-
) -> NDArray[Any]: ...
120+
) -> _nt.Array[Any]: ...
121121

122122
#
123123
@overload
@@ -126,21 +126,21 @@ def hstack(
126126
*,
127127
dtype: None = None,
128128
casting: np._CastingKind = "same_kind",
129-
) -> NDArray[_ScalarT]: ...
129+
) -> _nt.Array[_ScalarT]: ...
130130
@overload
131131
def hstack(
132132
tup: Sequence[ArrayLike],
133133
*,
134134
dtype: _DTypeLike[_ScalarT],
135135
casting: np._CastingKind = "same_kind",
136-
) -> NDArray[_ScalarT]: ...
136+
) -> _nt.Array[_ScalarT]: ...
137137
@overload
138138
def hstack(
139139
tup: Sequence[ArrayLike],
140140
*,
141141
dtype: DTypeLike | None = None,
142142
casting: np._CastingKind = "same_kind",
143-
) -> NDArray[Any]: ...
143+
) -> _nt.Array[Any]: ...
144144

145145
#
146146
@overload
@@ -151,7 +151,7 @@ def stack(
151151
*,
152152
dtype: None = None,
153153
casting: np._CastingKind = "same_kind",
154-
) -> NDArray[_ScalarT]: ...
154+
) -> _nt.Array[_ScalarT]: ...
155155
@overload
156156
def stack(
157157
arrays: Sequence[ArrayLike],
@@ -160,7 +160,7 @@ def stack(
160160
*,
161161
dtype: _DTypeLike[_ScalarT],
162162
casting: np._CastingKind = "same_kind",
163-
) -> NDArray[_ScalarT]: ...
163+
) -> _nt.Array[_ScalarT]: ...
164164
@overload
165165
def stack(
166166
arrays: Sequence[ArrayLike],
@@ -169,7 +169,7 @@ def stack(
169169
*,
170170
dtype: DTypeLike | None = None,
171171
casting: np._CastingKind = "same_kind",
172-
) -> NDArray[Any]: ...
172+
) -> _nt.Array[Any]: ...
173173
@overload
174174
def stack(
175175
arrays: Sequence[ArrayLike],
@@ -191,12 +191,12 @@ def stack(
191191

192192
#
193193
@overload
194-
def unstack(array: _ArrayLike[_ScalarT], /, *, axis: SupportsIndex = 0) -> tuple[NDArray[_ScalarT], ...]: ...
194+
def unstack(array: _ArrayLike[_ScalarT], /, *, axis: SupportsIndex = 0) -> tuple[_nt.Array[_ScalarT], ...]: ...
195195
@overload
196-
def unstack(array: ArrayLike, /, *, axis: SupportsIndex = 0) -> tuple[NDArray[Any], ...]: ...
196+
def unstack(array: ArrayLike, /, *, axis: SupportsIndex = 0) -> tuple[_nt.Array[Any], ...]: ...
197197

198198
#
199199
@overload
200-
def block(arrays: _ArrayLike[_ScalarT]) -> NDArray[_ScalarT]: ...
200+
def block(arrays: _ArrayLike[_ScalarT]) -> _nt.Array[_ScalarT]: ...
201201
@overload
202-
def block(arrays: ArrayLike) -> NDArray[Any]: ...
202+
def block(arrays: ArrayLike) -> _nt.Array[Any]: ...

0 commit comments

Comments
 (0)