This repository was archived by the owner on Jun 10, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy path__init__.pyi
1078 lines (1012 loc) · 31.2 KB
/
__init__.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import builtins
import sys
import datetime as dt
from abc import abstractmethod, ABCMeta
from numpy.core._internal import _ctypes
from numpy.typing import ArrayLike, DtypeLike, _Shape, _ShapeLike
from typing import (
Any,
ByteString,
Callable,
Container,
Callable,
Dict,
Generic,
IO,
Iterable,
List,
Mapping,
Optional,
overload,
Sequence,
Sized,
SupportsAbs,
SupportsComplex,
SupportsFloat,
SupportsInt,
Text,
Tuple,
Type,
TypeVar,
Union,
)
if sys.version_info[0] < 3:
class SupportsBytes: ...
else:
from typing import SupportsBytes
if sys.version_info >= (3, 8):
from typing import Literal, Protocol
else:
from typing_extensions import Literal, Protocol
# TODO: remove when the full numpy namespace is defined
def __getattr__(name: str) -> Any: ...
_NdArraySubClass = TypeVar("_NdArraySubClass", bound=ndarray)
class dtype:
names: Optional[Tuple[str, ...]]
def __init__(self, obj: DtypeLike, align: bool = ..., copy: bool = ...) -> None: ...
def __eq__(self, other: DtypeLike) -> bool: ...
def __ne__(self, other: DtypeLike) -> bool: ...
def __gt__(self, other: DtypeLike) -> bool: ...
def __ge__(self, other: DtypeLike) -> bool: ...
def __lt__(self, other: DtypeLike) -> bool: ...
def __le__(self, other: DtypeLike) -> bool: ...
@property
def alignment(self) -> int: ...
@property
def base(self) -> dtype: ...
@property
def byteorder(self) -> str: ...
@property
def char(self) -> str: ...
@property
def descr(self) -> List[Union[Tuple[str, str], Tuple[str, str, _Shape]]]: ...
@property
def fields(
self,
) -> Optional[Mapping[str, Union[Tuple[dtype, int], Tuple[dtype, int, Any]]]]: ...
@property
def flags(self) -> int: ...
@property
def hasobject(self) -> bool: ...
@property
def isbuiltin(self) -> int: ...
@property
def isnative(self) -> bool: ...
@property
def isalignedstruct(self) -> bool: ...
@property
def itemsize(self) -> int: ...
@property
def kind(self) -> str: ...
@property
def metadata(self) -> Optional[Mapping[str, Any]]: ...
@property
def name(self) -> str: ...
@property
def num(self) -> int: ...
@property
def shape(self) -> _Shape: ...
@property
def ndim(self) -> int: ...
@property
def subdtype(self) -> Optional[Tuple[dtype, _Shape]]: ...
def newbyteorder(self, new_order: str = ...) -> dtype: ...
# Leave str and type for end to avoid having to use `builtins.str`
# everywhere. See https://github.com/python/mypy/issues/3775
@property
def str(self) -> builtins.str: ...
@property
def type(self) -> Type[generic]: ...
_Dtype = dtype # to avoid name conflicts with ndarray.dtype
class _flagsobj:
aligned: bool
updateifcopy: bool
writeable: bool
writebackifcopy: bool
@property
def behaved(self) -> bool: ...
@property
def c_contiguous(self) -> bool: ...
@property
def carray(self) -> bool: ...
@property
def contiguous(self) -> bool: ...
@property
def f_contiguous(self) -> bool: ...
@property
def farray(self) -> bool: ...
@property
def fnc(self) -> bool: ...
@property
def forc(self) -> bool: ...
@property
def fortran(self) -> bool: ...
@property
def num(self) -> int: ...
@property
def owndata(self) -> bool: ...
def __getitem__(self, key: str) -> bool: ...
def __setitem__(self, key: str, value: bool) -> None: ...
_FlatIterSelf = TypeVar("_FlatIterSelf", bound=flatiter)
class flatiter(Generic[_ArraySelf]):
@property
def base(self) -> _ArraySelf: ...
@property
def coords(self) -> _Shape: ...
@property
def index(self) -> int: ...
def copy(self) -> _ArraySelf: ...
def __iter__(self: _FlatIterSelf) -> _FlatIterSelf: ...
def __next__(self) -> generic: ...
_ArraySelf = TypeVar("_ArraySelf", bound=_ArrayOrScalarCommon)
class _ArrayOrScalarCommon(
SupportsInt, SupportsFloat, SupportsComplex, SupportsBytes, SupportsAbs[Any]
):
@property
def T(self: _ArraySelf) -> _ArraySelf: ...
@property
def base(self) -> Optional[ndarray]: ...
@property
def dtype(self) -> _Dtype: ...
@property
def data(self) -> memoryview: ...
@property
def flags(self) -> _flagsobj: ...
@property
def size(self) -> int: ...
@property
def itemsize(self) -> int: ...
@property
def nbytes(self) -> int: ...
@property
def ndim(self) -> int: ...
@property
def shape(self) -> _Shape: ...
@property
def strides(self) -> _Shape: ...
def __array__(self, __dtype: DtypeLike = ...) -> ndarray: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __complex__(self) -> complex: ...
if sys.version_info[0] < 3:
def __oct__(self) -> str: ...
def __hex__(self) -> str: ...
def __nonzero__(self) -> bool: ...
def __unicode__(self) -> Text: ...
else:
def __bool__(self) -> bool: ...
def __bytes__(self) -> bytes: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __copy__(self: _ArraySelf, order: str = ...) -> _ArraySelf: ...
def __deepcopy__(self: _ArraySelf, memo: dict) -> _ArraySelf: ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __add__(self, other): ...
def __radd__(self, other): ...
def __iadd__(self, other): ...
def __sub__(self, other): ...
def __rsub__(self, other): ...
def __isub__(self, other): ...
def __mul__(self, other): ...
def __rmul__(self, other): ...
def __imul__(self, other): ...
if sys.version_info[0] < 3:
def __div__(self, other): ...
def __rdiv__(self, other): ...
def __idiv__(self, other): ...
def __truediv__(self, other): ...
def __rtruediv__(self, other): ...
def __itruediv__(self, other): ...
def __floordiv__(self, other): ...
def __rfloordiv__(self, other): ...
def __ifloordiv__(self, other): ...
def __mod__(self, other): ...
def __rmod__(self, other): ...
def __imod__(self, other): ...
def __divmod__(self, other): ...
def __rdivmod__(self, other): ...
# NumPy's __pow__ doesn't handle a third argument
def __pow__(self, other): ...
def __rpow__(self, other): ...
def __ipow__(self, other): ...
def __lshift__(self, other): ...
def __rlshift__(self, other): ...
def __ilshift__(self, other): ...
def __rshift__(self, other): ...
def __rrshift__(self, other): ...
def __irshift__(self, other): ...
def __and__(self, other): ...
def __rand__(self, other): ...
def __iand__(self, other): ...
def __xor__(self, other): ...
def __rxor__(self, other): ...
def __ixor__(self, other): ...
def __or__(self, other): ...
def __ror__(self, other): ...
def __ior__(self, other): ...
if sys.version_info[:2] >= (3, 5):
def __matmul__(self, other): ...
def __rmatmul__(self, other): ...
def __neg__(self: _ArraySelf) -> _ArraySelf: ...
def __pos__(self: _ArraySelf) -> _ArraySelf: ...
def __abs__(self: _ArraySelf) -> _ArraySelf: ...
def __invert__(self: _ArraySelf) -> _ArraySelf: ...
# TODO(shoyer): remove when all methods are defined
def __getattr__(self, name) -> Any: ...
_BufferType = Union[ndarray, bytes, bytearray, memoryview]
class ndarray(_ArrayOrScalarCommon, Iterable, Sized, Container):
@property
def real(self: _ArraySelf) -> _ArraySelf: ...
@real.setter
def real(self, value: ArrayLike) -> None: ...
@property
def imag(self: _ArraySelf) -> _ArraySelf: ...
@imag.setter
def imag(self, value: ArrayLike) -> None: ...
def __new__(
cls: Type[_ArraySelf],
shape: Sequence[int],
dtype: DtypeLike = ...,
buffer: _BufferType = ...,
offset: int = ...,
strides: _ShapeLike = ...,
order: Optional[str] = ...,
) -> _ArraySelf: ...
@property
def dtype(self) -> _Dtype: ...
@property
def ctypes(self) -> _ctypes: ...
@property
def shape(self) -> _Shape: ...
@shape.setter
def shape(self, value: _ShapeLike): ...
@property
def flat(self: _ArraySelf) -> flatiter[_ArraySelf]: ...
@property
def strides(self) -> _Shape: ...
@strides.setter
def strides(self, value: _ShapeLike): ...
# Array conversion
@overload
def item(self, *args: int) -> Any: ...
@overload
def item(self, args: Tuple[int, ...]) -> Any: ...
def tolist(self) -> List[Any]: ...
@overload
def itemset(self, __value: Any) -> None: ...
@overload
def itemset(self, __item: _ShapeLike, __value: Any) -> None: ...
def tostring(self, order: Optional[str] = ...) -> bytes: ...
def tobytes(self, order: Optional[str] = ...) -> bytes: ...
def tofile(
self, fid: Union[IO[bytes], str], sep: str = ..., format: str = ...
) -> None: ...
def dump(self, file: str) -> None: ...
def dumps(self) -> bytes: ...
def astype(
self: _ArraySelf,
dtype: DtypeLike,
order: str = ...,
casting: str = ...,
subok: bool = ...,
copy: bool = ...,
) -> _ArraySelf: ...
def byteswap(self: _ArraySelf, inplace: bool = ...) -> _ArraySelf: ...
def copy(self: _ArraySelf, order: str = ...) -> _ArraySelf: ...
@overload
def view(self, type: Type[_NdArraySubClass]) -> _NdArraySubClass: ...
@overload
def view(self: _ArraySelf, dtype: DtypeLike = ...) -> _ArraySelf: ...
@overload
def view(
self, dtype: DtypeLike, type: Type[_NdArraySubClass]
) -> _NdArraySubClass: ...
def getfield(
self: _ArraySelf, dtype: DtypeLike, offset: int = ...
) -> _ArraySelf: ...
def setflags(
self, write: bool = ..., align: bool = ..., uic: bool = ...
) -> None: ...
def fill(self, value: Any) -> None: ...
# Shape manipulation
@overload
def reshape(
self: _ArraySelf, shape: Sequence[int], *, order: str = ...
) -> _ArraySelf: ...
@overload
def reshape(self: _ArraySelf, *shape: int, order: str = ...) -> _ArraySelf: ...
@overload
def resize(self, new_shape: Sequence[int], *, refcheck: bool = ...) -> None: ...
@overload
def resize(self, *new_shape: int, refcheck: bool = ...) -> None: ...
@overload
def transpose(self: _ArraySelf, axes: Sequence[int]) -> _ArraySelf: ...
@overload
def transpose(self: _ArraySelf, *axes: int) -> _ArraySelf: ...
def swapaxes(self: _ArraySelf, axis1: int, axis2: int) -> _ArraySelf: ...
def flatten(self: _ArraySelf, order: str = ...) -> _ArraySelf: ...
def ravel(self: _ArraySelf, order: str = ...) -> _ArraySelf: ...
def squeeze(
self: _ArraySelf, axis: Union[int, Tuple[int, ...]] = ...
) -> _ArraySelf: ...
# Many of these special methods are irrelevant currently, since protocols
# aren't supported yet. That said, I'm adding them for completeness.
# https://docs.python.org/3/reference/datamodel.html
def __len__(self) -> int: ...
def __getitem__(self, key) -> Any: ...
def __setitem__(self, key, value): ...
def __iter__(self) -> Any: ...
def __contains__(self, key) -> bool: ...
def __index__(self) -> int: ...
# NOTE: while `np.generic` is not technically an instance of `ABCMeta`,
# the `@abstractmethod` decorator is herein used to (forcefully) deny
# the creation of `np.generic` instances.
# The `# type: ignore` comments are necessary to silence mypy errors regarding
# the missing `ABCMeta` metaclass.
# See https://github.com/numpy/numpy-stubs/pull/80 for more details.
class generic(_ArrayOrScalarCommon):
@abstractmethod
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@property
def base(self) -> None: ...
class _real_generic(generic): # type: ignore
@property
def real(self: _ArraySelf) -> _ArraySelf: ...
@property
def imag(self: _ArraySelf) -> _ArraySelf: ...
class number(generic): ... # type: ignore
class bool_(_real_generic):
def __init__(self, value: object = ...) -> None: ...
class object_(generic):
def __init__(self, value: object = ...) -> None: ...
class datetime64:
@overload
def __init__(
self, _data: Union[datetime64, str, dt.datetime] = ..., _format: str = ...
) -> None: ...
@overload
def __init__(self, _data: int, _format: str) -> None: ...
def __add__(self, other: Union[timedelta64, int]) -> datetime64: ...
def __sub__(self, other: Union[timedelta64, datetime64, int]) -> timedelta64: ...
class integer(number, _real_generic): ... # type: ignore
class signedinteger(integer): ... # type: ignore
class int8(signedinteger):
def __init__(self, value: SupportsInt = ...) -> None: ...
class int16(signedinteger):
def __init__(self, value: SupportsInt = ...) -> None: ...
class int32(signedinteger):
def __init__(self, value: SupportsInt = ...) -> None: ...
class int64(signedinteger):
def __init__(self, value: SupportsInt = ...) -> None: ...
class timedelta64(signedinteger):
def __init__(self, _data: Any = ..., _format: str = ...) -> None: ...
@overload
def __add__(self, other: Union[timedelta64, int]) -> timedelta64: ...
@overload
def __add__(self, other: datetime64) -> datetime64: ...
def __sub__(self, other: Union[timedelta64, int]) -> timedelta64: ...
if sys.version_info[0] < 3:
@overload
def __div__(self, other: timedelta64) -> float: ...
@overload
def __div__(self, other: float) -> timedelta64: ...
@overload
def __truediv__(self, other: timedelta64) -> float: ...
@overload
def __truediv__(self, other: float) -> timedelta64: ...
def __mod__(self, other: timedelta64) -> timedelta64: ...
class unsignedinteger(integer): ... # type: ignore
class uint8(unsignedinteger):
def __init__(self, value: SupportsInt = ...) -> None: ...
class uint16(unsignedinteger):
def __init__(self, value: SupportsInt = ...) -> None: ...
class uint32(unsignedinteger):
def __init__(self, value: SupportsInt = ...) -> None: ...
class uint64(unsignedinteger):
def __init__(self, value: SupportsInt = ...) -> None: ...
class inexact(number): ... # type: ignore
class floating(inexact, _real_generic): ... # type: ignore
class float16(floating):
def __init__(self, value: SupportsFloat = ...) -> None: ...
class float32(floating):
def __init__(self, value: SupportsFloat = ...) -> None: ...
class float64(floating):
def __init__(self, value: SupportsFloat = ...) -> None: ...
class complexfloating(inexact): ... # type: ignore
class complex64(complexfloating):
def __init__(
self, value: Union[SupportsInt, SupportsFloat, SupportsComplex] = ...
) -> None: ...
@property
def real(self) -> float32: ...
@property
def imag(self) -> float32: ...
class complex128(complexfloating):
def __init__(
self, value: Union[SupportsInt, SupportsFloat, SupportsComplex] = ...
) -> None: ...
@property
def real(self) -> float64: ...
@property
def imag(self) -> float64: ...
class flexible(_real_generic): ... # type: ignore
class void(flexible):
def __init__(self, value: Union[int, integer, bool_, bytes, bytes_]): ...
class character(_real_generic): ... # type: ignore
class bytes_(character):
@overload
def __init__(self, value: object = ...) -> None: ...
@overload
def __init__(
self, value: object, encoding: str = ..., errors: str = ...
) -> None: ...
class str_(character):
@overload
def __init__(self, value: object = ...) -> None: ...
@overload
def __init__(
self, value: object, encoding: str = ..., errors: str = ...
) -> None: ...
# TODO(alan): Platform dependent types
# longcomplex, longdouble, longfloat
# bytes, short, intc, intp, longlong
# half, single, double, longdouble
# uint_, int_, float_, complex_
# float128, complex256
# float96
def array(
object: object,
dtype: DtypeLike = ...,
copy: bool = ...,
subok: bool = ...,
ndmin: int = ...,
) -> ndarray: ...
def zeros(
shape: _ShapeLike, dtype: DtypeLike = ..., order: Optional[str] = ...
) -> ndarray: ...
def ones(
shape: _ShapeLike, dtype: DtypeLike = ..., order: Optional[str] = ...
) -> ndarray: ...
def empty(
shape: _ShapeLike, dtype: DtypeLike = ..., order: Optional[str] = ...
) -> ndarray: ...
def zeros_like(
a: ArrayLike,
dtype: DtypeLike = ...,
order: str = ...,
subok: bool = ...,
shape: Optional[Union[int, Sequence[int]]] = ...,
) -> ndarray: ...
def ones_like(
a: ArrayLike,
dtype: DtypeLike = ...,
order: str = ...,
subok: bool = ...,
shape: Optional[_ShapeLike] = ...,
) -> ndarray: ...
def empty_like(
a: ArrayLike,
dtype: DtypeLike = ...,
order: str = ...,
subok: bool = ...,
shape: Optional[_ShapeLike] = ...,
) -> ndarray: ...
def full(
shape: _ShapeLike, fill_value: Any, dtype: DtypeLike = ..., order: str = ...
) -> ndarray: ...
def full_like(
a: ArrayLike,
fill_value: Any,
dtype: DtypeLike = ...,
order: str = ...,
subok: bool = ...,
shape: Optional[_ShapeLike] = ...,
) -> ndarray: ...
def count_nonzero(
a: ArrayLike, axis: Optional[Union[int, Tuple[int], Tuple[int, int]]] = ...
) -> Union[int, ndarray]: ...
def isfortran(a: ndarray) -> bool: ...
def argwhere(a: ArrayLike) -> ndarray: ...
def flatnonzero(a: ArrayLike) -> ndarray: ...
def correlate(a: ArrayLike, v: ArrayLike, mode: str = ...) -> ndarray: ...
def convolve(a: ArrayLike, v: ArrayLike, mode: str = ...) -> ndarray: ...
def outer(a: ArrayLike, b: ArrayLike, out: ndarray = ...) -> ndarray: ...
def tensordot(
a: ArrayLike,
b: ArrayLike,
axes: Union[
int, Tuple[int, int], Tuple[Tuple[int, int], ...], Tuple[List[int, int], ...]
] = ...,
) -> ndarray: ...
def roll(
a: ArrayLike,
shift: Union[int, Tuple[int, ...]],
axis: Optional[Union[int, Tuple[int, ...]]] = ...,
) -> ndarray: ...
def rollaxis(a: ArrayLike, axis: int, start: int = ...) -> ndarray: ...
def moveaxis(
a: ndarray,
source: Union[int, Sequence[int]],
destination: Union[int, Sequence[int]],
) -> ndarray: ...
def cross(
a: ArrayLike,
b: ArrayLike,
axisa: int = ...,
axisb: int = ...,
axisc: int = ...,
axis: Optional[int] = ...,
) -> ndarray: ...
def indices(
dimensions: Sequence[int], dtype: dtype = ..., sparse: bool = ...
) -> Union[ndarray, Tuple[ndarray, ...]]: ...
def fromfunction(function: Callable, shape: Tuple[int, int], **kwargs) -> Any: ...
def isscalar(element: Any) -> bool: ...
def binary_repr(num: int, width: Optional[int] = ...) -> str: ...
def base_repr(number: int, base: int = ..., padding: int = ...) -> str: ...
def identity(n: int, dtype: DtypeLike = ...) -> ndarray: ...
def allclose(
a: ArrayLike,
b: ArrayLike,
rtol: float = ...,
atol: float = ...,
equal_nan: bool = ...,
) -> bool: ...
def isclose(
a: ArrayLike,
b: ArrayLike,
rtol: float = ...,
atol: float = ...,
equal_nan: bool = ...,
) -> Union[bool_, ndarray]: ...
def array_equal(a1: ArrayLike, a2: ArrayLike) -> bool: ...
def array_equiv(a1: ArrayLike, a2: ArrayLike) -> bool: ...
#
# Constants
#
Inf: float
Infinity: float
NAN: float
NINF: float
NZERO: float
NaN: float
PINF: float
PZERO: float
e: float
euler_gamma: float
inf: float
infty: float
nan: float
pi: float
ALLOW_THREADS: int
BUFSIZE: int
CLIP: int
ERR_CALL: int
ERR_DEFAULT: int
ERR_IGNORE: int
ERR_LOG: int
ERR_PRINT: int
ERR_RAISE: int
ERR_WARN: int
FLOATING_POINT_SUPPORT: int
FPE_DIVIDEBYZERO: int
FPE_INVALID: int
FPE_OVERFLOW: int
FPE_UNDERFLOW: int
MAXDIMS: int
MAY_SHARE_BOUNDS: int
MAY_SHARE_EXACT: int
RAISE: int
SHIFT_DIVIDEBYZERO: int
SHIFT_INVALID: int
SHIFT_OVERFLOW: int
SHIFT_UNDERFLOW: int
UFUNC_BUFSIZE_DEFAULT: int
WRAP: int
little_endian: int
tracemalloc_domain: int
class ufunc:
@property
def __name__(self) -> str: ...
def __call__(
self,
*args: ArrayLike,
out: Optional[Union[ndarray, Tuple[ndarray, ...]]] = ...,
where: Optional[ndarray] = ...,
# The list should be a list of tuples of ints, but since we
# don't know the signature it would need to be
# Tuple[int, ...]. But, since List is invariant something like
# e.g. List[Tuple[int, int]] isn't a subtype of
# List[Tuple[int, ...]], so we can't type precisely here.
axes: List[Any] = ...,
axis: int = ...,
keepdims: bool = ...,
# TODO: make this precise when we can use Literal.
casting: str = ...,
# TODO: make this precise when we can use Literal.
order: Optional[str] = ...,
dtype: DtypeLike = ...,
subok: bool = ...,
signature: Union[str, Tuple[str]] = ...,
# In reality this should be a length of list 3 containing an
# int, an int, and a callable, but there's no way to express
# that.
extobj: List[Union[int, Callable]] = ...,
) -> Union[ndarray, generic]: ...
@property
def nin(self) -> int: ...
@property
def nout(self) -> int: ...
@property
def nargs(self) -> int: ...
@property
def ntypes(self) -> int: ...
@property
def types(self) -> List[str]: ...
# Broad return type because it has to encompass things like
#
# >>> np.logical_and.identity is True
# True
# >>> np.add.identity is 0
# True
# >>> np.sin.identity is None
# True
#
# and any user-defined ufuncs.
@property
def identity(self) -> Any: ...
# This is None for ufuncs and a string for gufuncs.
@property
def signature(self) -> Optional[str]: ...
# The next four methods will always exist, but they will just
# raise a ValueError ufuncs with that don't accept two input
# arguments and return one output argument. Because of that we
# can't type them very precisely.
@property
def reduce(self) -> Any: ...
@property
def accumulate(self) -> Any: ...
@property
def reduceat(self) -> Any: ...
@property
def outer(self) -> Any: ...
# Similarly at won't be defined for ufuncs that return multiple
# outputs, so we can't type it very precisely.
@property
def at(self) -> Any: ...
absolute: ufunc
add: ufunc
arccos: ufunc
arccosh: ufunc
arcsin: ufunc
arcsinh: ufunc
arctan2: ufunc
arctan: ufunc
arctanh: ufunc
bitwise_and: ufunc
bitwise_or: ufunc
bitwise_xor: ufunc
cbrt: ufunc
ceil: ufunc
conjugate: ufunc
copysign: ufunc
cos: ufunc
cosh: ufunc
deg2rad: ufunc
degrees: ufunc
divmod: ufunc
equal: ufunc
exp2: ufunc
exp: ufunc
expm1: ufunc
fabs: ufunc
float_power: ufunc
floor: ufunc
floor_divide: ufunc
fmax: ufunc
fmin: ufunc
fmod: ufunc
frexp: ufunc
gcd: ufunc
greater: ufunc
greater_equal: ufunc
heaviside: ufunc
hypot: ufunc
invert: ufunc
isfinite: ufunc
isinf: ufunc
isnan: ufunc
isnat: ufunc
lcm: ufunc
ldexp: ufunc
left_shift: ufunc
less: ufunc
less_equal: ufunc
log10: ufunc
log1p: ufunc
log2: ufunc
log: ufunc
logaddexp2: ufunc
logaddexp: ufunc
logical_and: ufunc
logical_not: ufunc
logical_or: ufunc
logical_xor: ufunc
matmul: ufunc
maximum: ufunc
minimum: ufunc
modf: ufunc
multiply: ufunc
negative: ufunc
nextafter: ufunc
not_equal: ufunc
positive: ufunc
power: ufunc
rad2deg: ufunc
radians: ufunc
reciprocal: ufunc
remainder: ufunc
right_shift: ufunc
rint: ufunc
sign: ufunc
signbit: ufunc
sin: ufunc
sinh: ufunc
spacing: ufunc
sqrt: ufunc
square: ufunc
subtract: ufunc
tan: ufunc
tanh: ufunc
true_divide: ufunc
trunc: ufunc
# Warnings
class ModuleDeprecationWarning(DeprecationWarning): ...
class VisibleDeprecationWarning(UserWarning): ...
class ComplexWarning(RuntimeWarning): ...
class RankWarning(UserWarning): ...
# Errors
class TooHardError(RuntimeError): ...
class AxisError(ValueError, IndexError):
def __init__(
self, axis: int, ndim: Optional[int] = ..., msg_prefix: Optional[str] = ...
) -> None: ...
# Functions from np.core.numerictypes
_DefaultType = TypeVar("_DefaultType")
def maximum_sctype(t: DtypeLike) -> dtype: ...
def issctype(rep: object) -> bool: ...
@overload
def obj2sctype(rep: object) -> Optional[generic]: ...
@overload
def obj2sctype(rep: object, default: None) -> Optional[generic]: ...
@overload
def obj2sctype(
rep: object, default: Type[_DefaultType]
) -> Union[generic, Type[_DefaultType]]: ...
def issubclass_(arg1: object, arg2: Union[object, Tuple[object, ...]]) -> bool: ...
def issubsctype(
arg1: Union[ndarray, DtypeLike], arg2: Union[ndarray, DtypeLike]
) -> bool: ...
def issubdtype(arg1: DtypeLike, arg2: DtypeLike) -> bool: ...
def sctype2char(sctype: object) -> str: ...
def find_common_type(
array_types: Sequence[DtypeLike], scalar_types: Sequence[DtypeLike]
) -> dtype: ...
# Functions from np.core.fromnumeric
_Mode = Literal["raise", "wrap", "clip"]
_Order = Literal["C", "F", "A"]
_PartitionKind = Literal["introselect"]
_SortKind = Literal["quicksort", "mergesort", "heapsort", "stable"]
_Side = Literal["left", "right"]
# Various annotations for scalars
# While dt.datetime and dt.timedelta are not technically part of NumPy,
# they are one of the rare few builtin scalars which serve as valid return types.
# See https://github.com/numpy/numpy-stubs/pull/67#discussion_r412604113.
_ScalarNumpy = Union[generic, dt.datetime, dt.timedelta]
_ScalarBuiltin = Union[str, bytes, dt.date, dt.timedelta, bool, int, float, complex]
_Scalar = Union[_ScalarBuiltin, _ScalarNumpy]
# Integers and booleans can generally be used interchangeably
_ScalarIntOrBool = TypeVar("_ScalarIntOrBool", bound=Union[integer, bool_])
_ScalarGeneric = TypeVar("_ScalarGeneric", bound=generic)
_ScalarGenericDT = TypeVar(
"_ScalarGenericDT", bound=Union[dt.datetime, dt.timedelta, generic]
)
# An array-like object consisting of integers
_Int = Union[int, integer]
_Bool = Union[bool, bool_]
_IntOrBool = Union[_Int, _Bool]
_ArrayLikeIntNested = ArrayLike # TODO: wait for support for recursive types
_ArrayLikeBoolNested = ArrayLike # TODO: wait for support for recursive types
# Integers and booleans can generally be used interchangeably
_ArrayLikeIntOrBool = Union[
_IntOrBool,
ndarray,
Sequence[_IntOrBool],
Sequence[_ArrayLikeIntNested],
Sequence[_ArrayLikeBoolNested],
]
# The signature of take() follows a common theme with its overloads:
# 1. A generic comes in; the same generic comes out
# 2. A scalar comes in; a generic comes out
# 3. An array-like object comes in; some keyword ensures that a generic comes out
# 4. An array-like object comes in; an ndarray or generic comes out
@overload
def take(
a: _ScalarGenericDT,
indices: int,
axis: Optional[int] = ...,
out: Optional[ndarray] = ...,
mode: _Mode = ...,
) -> _ScalarGenericDT: ...
@overload
def take(
a: _Scalar,
indices: int,
axis: Optional[int] = ...,
out: Optional[ndarray] = ...,
mode: _Mode = ...,
) -> _ScalarNumpy: ...
@overload
def take(
a: ArrayLike,
indices: int,
axis: Optional[int] = ...,
out: Optional[ndarray] = ...,
mode: _Mode = ...,
) -> _ScalarNumpy: ...
@overload
def take(
a: ArrayLike,
indices: _ArrayLikeIntOrBool,
axis: Optional[int] = ...,
out: Optional[ndarray] = ...,
mode: _Mode = ...,
) -> Union[_ScalarNumpy, ndarray]: ...
def reshape(a: ArrayLike, newshape: _ShapeLike, order: _Order = ...) -> ndarray: ...
@overload
def choose(
a: _ScalarIntOrBool,
choices: Union[Sequence[ArrayLike], ndarray],
out: Optional[ndarray] = ...,
mode: _Mode = ...,
) -> _ScalarIntOrBool: ...
@overload
def choose(
a: _IntOrBool,
choices: Union[Sequence[ArrayLike], ndarray],
out: Optional[ndarray] = ...,
mode: _Mode = ...,
) -> Union[integer, bool_]: ...
@overload
def choose(
a: _ArrayLikeIntOrBool,
choices: Union[Sequence[ArrayLike], ndarray],
out: Optional[ndarray] = ...,
mode: _Mode = ...,
) -> ndarray: ...
def repeat(
a: ArrayLike, repeats: _ArrayLikeIntOrBool, axis: Optional[int] = ...
) -> ndarray: ...
def put(
a: ndarray, ind: _ArrayLikeIntOrBool, v: ArrayLike, mode: _Mode = ...
) -> None: ...
def swapaxes(
a: Union[Sequence[ArrayLike], ndarray], axis1: int, axis2: int
) -> ndarray: ...
def transpose(
a: ArrayLike, axes: Union[None, Sequence[int], ndarray] = ...
) -> ndarray: ...
def partition(
a: ArrayLike,
kth: _ArrayLikeIntOrBool,
axis: Optional[int] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> ndarray: ...
@overload
def argpartition(
a: generic,
kth: _ArrayLikeIntOrBool,
axis: Optional[int] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> integer: ...
@overload
def argpartition(
a: _ScalarBuiltin,
kth: _ArrayLikeIntOrBool,
axis: Optional[int] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> ndarray: ...
@overload
def argpartition(
a: ArrayLike,
kth: _ArrayLikeIntOrBool,
axis: Optional[int] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> ndarray: ...