8000 Completed typing rewrite · numpy/numpy@9aa367c · GitHub
[go: up one dir, main page]

Skip to content

Commit 9aa367c

Browse files
committed
Completed typing rewrite
1 parent 07ff08c commit 9aa367c

16 files changed

+283
-272
lines changed

numpy/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,17 @@
128128
array_str, asanyarray, asarray, ascontiguousarray, asfortranarray,
129129
atleast_1d, atleast_2d, atleast_3d, base_repr, binary_repr,
130130
bitwise_and, bitwise_count, bitwise_not, bitwise_or, bitwise_xor,
131-
block, bool, bool_, broadcast, busday_count, busday_offset, busdaycalendar,
132-
byte, bytes_, can_cast, cbrt, cdouble, ceil, character, choose, clip,
133-
clongdouble, complex128, complex64, complexfloating, compress,
134-
concatenate, conj, conjugate, convolve, copysign, copyto, correlate,
135-
cos, cosh, count_nonzero, cross, csingle, cumprod, cumproduct, cumsum,
136-
datetime64, datetime_as_string, datetime_data, deg2rad, degrees,
137-
diagonal, divide, divmod, dot, double, dtype, e, einsum, einsum_path,
138-
empty, empty_like, equal, errstate, euler_gamma, exp, exp2, expm1,
139-
fabs, finfo, flatiter, flatnonzero, flexible, float16, float32,
140-
float64, float_power, floating, floor, floor_divide, fmax, fmin, fmod,
131+
block, bool, bool_, broadcast, busday_count, busday_offset,
132+
busdaycalendar, byte, bytes_, can_cast, cbrt, cdouble, ceil,
133+
character, choose, clip, clongdouble, complex128, complex64,
134+
complexfloating, compress, concatenate, conj, conjugate, convolve,
135+
copysign, copyto, correlate, cos, cosh, count_nonzero, cross, csingle,
136+
cumprod, cumproduct, cumsum, datetime64, datetime_as_string,
137+
datetime_data, deg2rad, degrees, diagonal, divide, divmod, dot,
138+
double, dtype, e, einsum, einsum_path, empty, empty_like, equal,
139+
errstate, euler_gamma, exp, exp2, expm1, fabs, finfo, flatiter,
140+
flatnonzero, flexible, float16, float32, float64, float_power,
141+
floating, floor, floor_divide, fmax, fmin, fmod,
141142
format_float_positional, format_float_scientific, frexp, from_dlpack,
142143
frombuffer, fromfile, fromfunction, fromiter, frompyfunc, fromstring,
143144
full, full_like, gcd, generic, geomspace, get_printoptions,

numpy/_core/defchararray.pyi

Lines changed: 57 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import builtins
12
from typing import (
23
Literal as L,
34
overload,
@@ -13,7 +14,7 @@ from numpy import (
1314
str_,
1415
bytes_,
1516
int_,
16-
bool_,
17+
bool,
1718
object_,
1819
_OrderKACF,
1920
_ShapeType,
@@ -27,7 +28,7 @@ from numpy._typing import (
2728
_ArrayLikeStr_co as U_co,
2829
_ArrayLikeBytes_co as S_co,
2930
_ArrayLikeInt_co as i_co,
30-
_ArrayLikeBool_co as b_co,
31+
_ArrayLikeboolco as b_co,
3132
)
3233

3334
from numpy._core.multiarray import compare_chararrays as compare_chararrays
@@ -68,67 +69,67 @@ class chararray(ndarray[_ShapeType, _CharDType]):
6869
def __eq__(
6970
self: _CharArray[str_],
7071
other: U_co,
71-
) -> NDArray[bool_]: ...
72+
) -> NDArray[bool]: ...
7273
@overload
7374
def __eq__(
7475
self: _CharArray[bytes_],
7576
other: S_co,
76-
) -> NDArray[bool_]: ...
77+
) -> NDArray[bool]: ...
7778

7879
@overload
7980
def __ne__(
8081
self: _CharArray[str_],
8182
other: U_co,
82-
) -> NDArray[bool_]: ...
83+
) -> NDArray[bool]: ...
8384
@overload
8485
def __ne__(
8586
self: _CharArray[bytes_],
8687
other: S_co,
87-
) -> NDArray[bool_]: ...
88+
) -> NDArray[bool]: ...
8889

8990
@overload
9091
def __ge__(
9192
self: _CharArray[str_],
9293
other: U_co,
93-
) -> NDArray[bool_]: ...
94+
) -> NDArray[bool]: ...
9495
@overload
9596
def __ge__(
9697
self: _CharArray[bytes_],
9798
other: S_co,
98-
) -> NDArray[bool_]: ...
99+
) -> NDArray[bool]: ...
99100

100101
@overload
101102
def __le__(
102103
self: _CharArray[str_],
103104
other: U_co,
104-
) -> NDArray[bool_]: ...
105+
) -> NDArray[bool]: ...
105106
@overload
106107
def __le__(
107108
self: _CharArray[bytes_],
108109
other: S_co,
109-
) -> NDArray[bool_]: ...
110+
) -> NDArray[bool]: ...
110111

111112
@overload
112113
def __gt__(
113114
self: _CharArray[str_],
114115
other: U_co,
115-
) -> NDArray[bool_]: ...
116+
) -> NDArray[bool]: ...
116117
@overload
117118
def __gt__(
118119
self: _CharArray[bytes_],
119120
other: S_co,
120-
) -> NDArray[bool_]: ...
121+
) -> NDArray[bool]: ...
121122

122123
@overload
123124
def __lt__(
124125
self: _CharArray[str_],
125126
other: U_co,
126-
) -> NDArray[bool_]: ...
127+
) -> NDArray[bool]: ...
127128
@overload
128129
def __lt__(
129130
self: _CharArray[bytes_],
130131
other: S_co,
131-
) -> NDArray[bool_]: ...
132+
) -> NDArray[bool]: ...
132133

133134
@overload
134135
def __add__(
@@ -198,14 +199,14 @@ class chararray(ndarray[_ShapeType, _CharDType]):
198199
suffix: U_co,
199200
start: i_co = ...,
200201
end: None | i_co = ...,
201-
) -> NDArray[bool_]: ...
202+
) -> NDArray[bool]: ...
202203
@overload
203204
def endswith(
204205
self: _CharArray[bytes_],
205206
suffix: S_co,
206207
start: i_co = ...,
207208
end: None | i_co = ...,
208-
) -> NDArray[bool_]: ...
209+
) -> NDArray[bool]: ...
209210

210211
def expandtabs(
211212
self,
@@ -402,14 +403,14 @@ class chararray(ndarray[_ShapeType, _CharDType]):
402403
prefix: U_co,
403404
start: i_co = ...,
404405
end: None | i_co = ...,
405-
) -> NDArray[bool_]: ...
406+
) -> NDArray[bool]: ...
406407
@overload
407408
def startswith(
408409
self: _CharArray[bytes_],
409410
prefix: S_co,
410411
start: i_co = ...,
411412
end: None | i_co = ...,
412-
) -> NDArray[bool_]: ...
413+
) -> NDArray[bool]: ...
413414

414415
@overload
415416
def strip(
@@ -441,48 +442,48 @@ class chararray(ndarray[_ShapeType, _CharDType]):
441442
def swapcase(self) -> chararray[_ShapeType, _CharDType]: ...
442443
def lower(self) -> chararray[_ShapeType, _CharDType]: ...
443444
def upper(self) -> chararray[_ShapeType, _CharDType]: ...
444-
def isalnum(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
445-
def isalpha(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
446-
def isdigit(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
447-
def islower(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
448-
def isspace(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
449-
def istitle(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
450-
def isupper(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
451-
def isnumeric(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
452-
def isdecimal(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
445+
def isalnum(self) -> ndarray[_ShapeType, dtype[bool]]: ...
446+
def isalpha(self) -> ndarray[_ShapeType, dtype[bool]]: ...
447+
def isdigit(self) -> ndarray[_ShapeType, dtype[bool]]: ...
448+
def islower(self) -> ndarray[_ShapeType, dtype[bool]]: ...
449+
def isspace(self) -> ndarray[_ShapeType, dtype[bool]]: ...
450+
def istitle(self) -> ndarray[_ShapeType, dtype[bool]]: ...
451+
def isupper(self) -> ndarray[_ShapeType, dtype[bool]]: ...
452+
def isnumeric(self) -> ndarray[_ShapeType, dtype[bool]]: ...
453+
def isdecimal(self) -> ndarray[_ShapeType, dtype[bool]]: ...
453454

454455
__all__: list[str]
455456

456457
# Comparison
457458
@overload
458-
def equal(x1: U_co, x2: U_co) -> NDArray[bool_]: ...
459+
def equal(x1: U_co, x2: U_co) -> NDArray[bool]: ...
459460
@overload
460-
def equal(x1: S_co, x2: S_co) -> NDArray[bool_]: ...
461+
def equal(x1: S_co, x2: S_co) -> NDArray[bool]: ...
461462

462463
@overload
463-
def not_equal(x1: U_co, x2: U_co) -> NDArray[bool_]: ...
464+
def not_equal(x1: U_co, x2: U_co) -> NDArray[bool]: ...
464465
@overload
465-
def not_equal(x1: S_co, x2: S_co) -> NDArray[bool_]: ...
466+
def not_equal(x1: S_co, x2: S_co) -> NDArray[bool]: ...
466467

467468
@overload
468-
def greater_equal(x1: U_co, x2: U_co) -> NDArray[bool_]: ...
469+
def greater_equal(x1: U_co, x2: U_co) -> NDArray[bool]: ...
469470
@overload
470-
def greater_equal(x1: S_co, x2: S_co) -> NDArray[bool_]: ...
471+
def greater_equal(x1: S_co, x2: S_co) -> NDArray[bool]: ...
471472

472473
@overload
473-
def less_equal(x1: U_co, x2: U_co) -> NDArray[bool_]: ...
474+
def less_equal(x1: U_co, x2: U_co) -> NDArray[bool]: ...
474475
@overload
475-
def less_equal(x1: S_co, x2: S_co) -> NDArray[bool_]: ...
476+
def less_equal(x1: S_co, x2: S_co) -> NDArray[bool]: ...
476477

477478
@overload
478-
def greater(x1: U_co, x2: U_co) -> NDArray[bool_]: ...
479+
def greater(x1: U_co, x2: U_co) -> NDArray[bool]: ...
479480
@overload
480-
def greater(x1: S_co, x2: S_co) -> NDArray[bool_]: ...
481+
def greater(x1: S_co, x2: S_co) -> NDArray[bool]: ...
481482

482483
@overload
483-
def less(x1: U_co, x2: U_co) -> NDArray[bool_]: ...
484+
def less(x1: U_co, x2: U_co) -> NDArray[bool]: ...
484485
@overload
485-
def less(x1: S_co, x2: S_co) -> NDArray[bool_]: ...
486+
def less(x1: S_co, x2: S_co) -> NDArray[bool]: ...
486487

487488
# String operations
488489
@overload
@@ -681,14 +682,14 @@ def endswith(
681682
suffix: U_co,
682683
start: i_co = ...,
683684
end: None | i_co = ...,
684-
) -> NDArray[bool_]: ...
685+
) -> NDArray[bool]: ...
685686
@overload
686687
def endswith(
687688
a: S_co,
688689
suffix: S_co,
689690
start: i_co = ...,
690691
end: None | i_co = ...,
691-
) -> NDArray[bool_]: ...
692+
) -> NDArray[bool]: ...
692693

693694
@overload
694695
def find(
@@ -720,15 +721,15 @@ def index(
720721
end: None | i_co = ...,
721722
) -> NDArray[int_]: ...
722723

723-
def isalpha(a: U_co | S_co) -> NDArray[bool_]: ...
724-
def isalnum(a: U_co | S_co) -> NDArray[bool_]: ...
725-
def isdecimal(a: U_co | S_co) -> NDArray[bool_]: ...
726-
def isdigit(a: U_co | S_co) -> NDArray[bool_]: ...
727-
def islower(a: U_co | S_co) -> NDArray[bool_]: ...
728-
def isnumeric(a: U_co | S_co) -> NDArray[bool_]: ...
729-
def isspace(a: U_co | S_co) -> NDArray[bool_]: ...
730-
def istitle(a: U_co | S_co) -> NDArray[bool_]: ...
731-
def isupper(a: U_co | S_co) -> NDArray[bool_]: ...
724+
def isalpha(a: U_co | S_co) -> NDArray[bool]: ...
725+
def isalnum(a: U_co | S_co) -> NDArray[bool]: ...
726+
def isdecimal(a: U_co | S_co) -> NDArray[bool]: ...
727+
def isdigit(a: U_co | S_co) -> NDArray[bool]: ...
728+
def islower(a: U_co | S_co) -> NDArray[bool]: ...
729+
def isnumeric(a: U_co | S_co) -> NDArray[bool]: ...
730+
def isspace(a: U_co | S_co) -> NDArray[bool]: ...
731+
def istitle(a: U_co | S_co) -> NDArray[bool]: ...
732+
def isupper(a: U_co | S_co) -> NDArray[bool]: ...
732733

733734
@overload
734735
def rfind(
@@ -766,14 +767,14 @@ def startswith(
766767
prefix: U_co,
767768
start: i_co = ...,
768769
end: None | i_co = ...,
769-
) -> NDArray[bool_]: ...
770+
) -> NDArray[bool]: ...
770771
@overload
771772
def startswith(
772773
a: S_co,
773774
prefix: S_co,
774775
start: i_co = ...,
775776
end: None | i_co = ...,
776-
) -> NDArray[bool_]: ...
777+
) -> NDArray[bool]: ...
777778

778779
def str_len(A: U_co | S_co) -> NDArray[int_]: ...
779780

@@ -784,31 +785,31 @@ def str_len(A: U_co | S_co) -> NDArray[int_]: ...
784785
def array(
785786
obj: U_co,
786787
itemsize: None | int = ...,
787-
copy: bool = ...,
788+
copy: builtins.bool = ...,
788789
unicode: L[False] = ...,
789790
order: _OrderKACF = ...,
790791
) -> _CharArray[str_]: ...
791792
@overload
792793
def array(
793794
obj: S_co,
794795
itemsize: None | int = ...,
795-
copy: bool = ...,
796+
copy: builtins.bool = ...,
796797
unicode: L[False] = ...,
797798
order: _OrderKACF = ...,
798799
) -> _CharArray[bytes_]: ...
799800
@overload
800801
def array(
801802
obj: object,
802803
itemsize: None | int = ...,
803-
copy: bool = ...,
804+
copy: builtins.bool = ...,
804805
unicode: L[False] = ...,
805806
order: _OrderKACF = ...,
806807
) -> _CharArray[bytes_]: ...
807808
@overload
808809
def array(
809810
obj: object,
810811
itemsize: None | int = ...,
811-
copy: bool = ...,
812+
copy: builtins.bool = ...,
812813
unicode: L[True] = ...,
813814
order: _OrderKACF = ...,
814815
) -> _CharArray[str_]: ...

numpy/_core/einsumfunc.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import builtins
12
from collections.abc import Sequence
23
from typing import TypeVar, Any, overload, Literal
34

45
from numpy import (
5-
bool_,
6+
bool,
67
number,
78
_OrderKACF,
89
)
@@ -25,10 +26,10 @@ from numpy._typing import (
2526

2627
_ArrayType = TypeVar(
2728
"_ArrayType",
28-
bound=NDArray[bool_ | number[Any]],
29+
bound=NDArray[bool | number[Any]],
2930
)
3031

31-
_OptimizeKind = None | bool | Literal["greedy", "optimal"] | Sequence[Any]
32+
_OptimizeKind = None | builtins.bool | Literal["greedy", "optimal"] | Sequence[Any]
3233
_CastingSafe = Literal["no", "equiv", "safe", "same_kind"]
3334
_CastingUnsafe = Literal["unsafe"]
3435

0 commit comments

Comments
 (0)
0