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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
|
import builtins
import sys
import datetime as dt
from abc import abstractmethod
from types import TracebackType
from contextlib import ContextDecorator
from numpy.core._internal import _ctypes
from numpy.typing import (
# Arrays
ArrayLike,
# DTypes
DTypeLike,
_SupportsDType,
_VoidDTypeLike,
# Shapes
_Shape,
_ShapeLike,
# Scalars
_CharLike_co,
_BoolLike_co,
_IntLike_co,
_FloatLike_co,
_ComplexLike_co,
_TD64Like_co,
_NumberLike_co,
# `number` precision
NBitBase,
_256Bit,
_128Bit,
_96Bit,
_80Bit,
_64Bit,
_32Bit,
_16Bit,
_8Bit,
_NBitByte,
_NBitShort,
_NBitIntC,
_NBitIntP,
_NBitInt,
_NBitLongLong,
_NBitHalf,
_NBitSingle,
_NBitDouble,
_NBitLongDouble,
# Character codes
_BoolCodes,
_UInt8Codes,
_UInt16Codes,
_UInt32Codes,
_UInt64Codes,
_Int8Codes,
_Int16Codes,
_Int32Codes,
_Int64Codes,
_Float16Codes,
_Float32Codes,
_Float64Codes,
_Complex64Codes,
_Complex128Codes,
_ByteCodes,
_ShortCodes,
_IntCCodes,
_IntPCodes,
_IntCodes,
_LongLongCodes,
_UByteCodes,
_UShortCodes,
_UIntCCodes,
_UIntPCodes,
_UIntCodes,
_ULongLongCodes,
_HalfCodes,
_SingleCodes,
_DoubleCodes,
_LongDoubleCodes,
_CSingleCodes,
_CDoubleCodes,
_CLongDoubleCodes,
_DT64Codes,
_TD64Codes,
_StrCodes,
_BytesCodes,
_VoidCodes,
_ObjectCodes,
)
from numpy.typing._callable import (
_BoolOp,
_BoolBitOp,
_BoolSub,
_BoolTrueDiv,
_BoolMod,
_BoolDivMod,
_TD64Div,
_IntTrueDiv,
_UnsignedIntOp,
_UnsignedIntBitOp,
_UnsignedIntMod,
_UnsignedIntDivMod,
_SignedIntOp,
_SignedIntBitOp,
_SignedIntMod,
_SignedIntDivMod,
_FloatOp,
_FloatMod,
_FloatDivMod,
_ComplexOp,
_NumberOp,
_ComparisonOp,
)
from typing import (
Any,
ByteString,
Callable,
Container,
Callable,
Dict,
Generic,
IO,
Iterable,
List,
Mapping,
Optional,
overload,
Sequence,
Sized,
SupportsComplex,
SupportsFloat,
SupportsInt,
Text,
Tuple,
Type,
TypeVar,
Union,
)
if sys.version_info >= (3, 8):
from typing import Literal, Protocol, SupportsIndex, Final
else:
from typing_extensions import Literal, Protocol, Final
class SupportsIndex(Protocol):
def __index__(self) -> int: ...
# Ensures that the stubs are picked up
from numpy import (
char,
ctypeslib,
emath,
fft,
lib,
linalg,
ma,
matrixlib,
polynomial,
random,
rec,
testing,
version,
)
from numpy.core.function_base import (
linspace,
logspace,
geomspace,
)
from numpy.core.fromnumeric import (
take,
reshape,
choose,
repeat,
put,
swapaxes,
transpose,
partition,
argpartition,
sort,
argsort,
argmax,
argmin,
searchsorted,
resize,
squeeze,
diagonal,
trace,
ravel,
nonzero,
shape,
compress,
clip,
sum,
all,
any,
cumsum,
ptp,
amax,
amin,
prod,
cumprod,
ndim,
size,
around,
mean,
std,
var,
)
from numpy.core._asarray import (
asarray as asarray,
asanyarray as asanyarray,
ascontiguousarray as ascontiguousarray,
asfortranarray as asfortranarray,
require as require,
)
from numpy.core._type_aliases import (
sctypes as sctypes,
sctypeDict as sctypeDict,
)
from numpy.core._ufunc_config import (
seterr as seterr,
geterr as geterr,
setbufsize as setbufsize,
getbufsize as getbufsize,
seterrcall as seterrcall,
geterrcall as geterrcall,
_SupportsWrite,
_ErrKind,
_ErrFunc,
_ErrDictOptional,
)
from numpy.core.arrayprint import (
set_printoptions as set_printoptions,
get_printoptions as get_printoptions,
array2string as array2string,
format_float_scientific as format_float_scientific,
format_float_positional as format_float_positional,
array_repr as array_repr,
array_str as array_str,
set_string_function as set_string_function,
printoptions as printoptions,
)
from numpy.core.numeric import (
zeros_like as zeros_like,
ones as ones,
ones_like as ones_like,
empty_like as empty_like,
full as full,
full_like as full_like,
count_nonzero as count_nonzero,
isfortran as isfortran,
argwhere as argwhere,
flatnonzero as flatnonzero,
correlate as correlate,
convolve as convolve,
outer as outer,
tensordot as tensordot,
roll as roll,
rollaxis as rollaxis,
moveaxis as moveaxis,
cross as cross,
indices as indices,
fromfunction as fromfunction,
isscalar as isscalar,
binary_repr as binary_repr,
base_repr as base_repr,
identity as identity,
allclose as allclose,
isclose as isclose,
array_equal as array_equal,
array_equiv as array_equiv,
)
from numpy.core.numerictypes import (
maximum_sctype as maximum_sctype,
issctype as issctype,
obj2sctype as obj2sctype,
issubclass_ as issubclass_,
issubsctype as issubsctype,
issubdtype as issubdtype,
sctype2char as sctype2char,
find_common_type as find_common_type,
)
from numpy.core.shape_base import (
atleast_1d as atleast_1d,
atleast_2d as atleast_2d,
atleast_3d as atleast_3d,
block as block,
hstack as hstack,
stack as stack,
vstack as vstack,
)
# Add an object to `__all__` if their stubs are defined in an external file;
# their stubs will not be recognized otherwise.
# NOTE: This is redundant for objects defined within this file.
__all__ = [
"linspace",
"logspace",
"geomspace",
"take",
"reshape",
"choose",
"repeat",
"put",
"swapaxes",
"transpose",
"partition",
"argpartition",
"sort",
"argsort",
"argmax",
"argmin",
"searchsorted",
"resize",
"squeeze",
"diagonal",
"trace",
"ravel",
"nonzero",
"shape",
"compress",
"clip",
"sum",
"all",
"any",
"cumsum",
"ptp",
"amax",
"amin",
"prod",
"cumprod",
"ndim",
"size",
"around",
"mean",
"std",
"var",
]
DataSource: Any
MachAr: Any
ScalarType: Any
angle: Any
append: Any
apply_along_axis: Any
apply_over_axes: Any
arange: Any
array_split: Any
asarray_chkfinite: Any
asfarray: Any
asmatrix: Any
asscalar: Any
average: Any
bartlett: Any
bincount: Any
bitwise_not: Any
blackman: Any
bmat: Any
bool8: Any
broadcast: Any
broadcast_arrays: Any
broadcast_to: Any
busday_count: Any
busday_offset: Any
busdaycalendar: Any
byte_bounds: Any
bytes0: Any
c_: Any
can_cast: Any
cast: Any
chararray: Any
column_stack: Any
common_type: Any
compare_chararrays: Any
complex256: Any
concatenate: Any
conj: Any
copy: Any
copyto: Any
corrcoef: Any
cov: Any
cumproduct: Any
datetime_as_string: Any
datetime_data: Any
delete: Any
deprecate: Any
deprecate_with_doc: Any
diag: Any
diag_indices: Any
diag_indices_from: Any
diagflat: Any
diff: Any
digitize: Any
disp: Any
divide: Any
dot: Any
dsplit: Any
dstack: Any
ediff1d: Any
einsum: Any
einsum_path: Any
expand_dims: Any
extract: Any
eye: Any
fill_diagonal: Any
finfo: Any
fix: Any
flip: Any
fliplr: Any
flipud: Any
float128: Any
format_parser: Any
frombuffer: Any
fromfile: Any
fromiter: Any
frompyfunc: Any
fromregex: Any
fromstring: Any
genfromtxt: Any
get_include: Any
geterrobj: Any
gradient: Any
hamming: Any
hanning: Any
histogram: Any
histogram2d: Any
histogram_bin_edges: Any
histogramdd: Any
hsplit: Any
i0: Any
iinfo: Any
imag: Any
in1d: Any
index_exp: Any
info: Any
inner: Any
insert: Any
interp: Any
intersect1d: Any
is_busday: Any
iscomplex: Any
iscomplexobj: Any
isin: Any
isneginf: Any
isposinf: Any
isreal: Any
isrealobj: Any
iterable: Any
ix_: Any
kaiser: Any
kron: Any
lexsort: Any
load: Any
loads: Any
loadtxt: Any
lookfor: Any
mafromtxt: Any
mask_indices: Any
mat: Any
matrix: Any
max: Any
may_share_memory: Any
median: Any
memmap: Any
meshgrid: Any
mgrid: Any
min: Any
min_scalar_type: Any
mintypecode: Any
mod: Any
msort: Any
nan_to_num: Any
nanargmax: Any
nanargmin: Any
nancumprod: Any
nancumsum: Any
nanmax: Any
nanmean: Any
nanmedian: Any
nanmin: Any
nanpercentile: Any
nanprod: Any
nanquantile: Any
nanstd: Any
nansum: Any
nanvar: Any
nbytes: Any
ndenumerate: Any
ndfromtxt: Any
ndindex: Any
nditer: Any
nested_iters: Any
newaxis: Any
numarray: Any
object0: Any
ogrid: Any
packbits: Any
pad: Any
percentile: Any
piecewise: Any
place: Any
poly: Any
poly1d: Any
polyadd: Any
polyder: Any
polydiv: Any
polyfit: Any
polyint: Any
polymul: Any
polysub: Any
polyval: Any
product: Any
promote_types: Any
put_along_axis: Any
putmask: Any
quantile: Any
r_: Any
ravel_multi_index: Any
real: Any
real_if_close: Any
recarray: Any
recfromcsv: Any
recfromtxt: Any
record: Any
result_type: Any
roots: Any
rot90: Any
round: Any
round_: Any
row_stack: Any
s_: Any
save: Any
savetxt: Any
savez: Any
savez_compressed: Any
select: Any
setdiff1d: Any
seterrobj: Any
setxor1d: Any
shares_memory: Any
show_config: Any
sinc: Any
sort_complex: Any
source: Any
split: Any
string_: Any
take_along_axis: Any
tile: Any
trapz: Any
tri: Any
tril: Any
tril_indices: Any
tril_indices_from: Any
trim_zeros: Any
triu: Any
triu_indices: Any
triu_indices_from: Any
typeDict: Any
typecodes: Any
typename: Any
union1d: Any
unique: Any
unpackbits: Any
unravel_index: Any
unwrap: Any
vander: Any
vdot: Any
vectorize: Any
void0: Any
vsplit: Any
where: Any
who: Any
_NdArraySubClass = TypeVar("_NdArraySubClass", bound=ndarray)
_DTypeScalar = TypeVar("_DTypeScalar", bound=generic)
_ByteOrder = Literal["S", "<", ">", "=", "|", "L", "B", "N", "I"]
class dtype(Generic[_DTypeScalar]):
names: Optional[Tuple[str, ...]]
# Overload for subclass of generic
@overload
def __new__(
cls,
dtype: Type[_DTypeScalar],
align: bool = ...,
copy: bool = ...,
) -> dtype[_DTypeScalar]: ...
# Overloads for string aliases, Python types, and some assorted
# other special cases. Order is sometimes important because of the
# subtype relationships
#
# bool < int < float < complex
#
# so we have to make sure the overloads for the narrowest type is
# first.
# Builtin types
@overload
def __new__(cls, dtype: Type[bool], align: bool = ..., copy: bool = ...) -> dtype[bool_]: ...
@overload
def __new__(cls, dtype: Type[int], align: bool = ..., copy: bool = ...) -> dtype[int_]: ...
@overload
def __new__(cls, dtype: Optional[Type[float]], align: bool = ..., copy: bool = ...) -> dtype[float_]: ...
@overload
def __new__(cls, dtype: Type[complex], align: bool = ..., copy: bool = ...) -> dtype[complex_]: ...
@overload
def __new__(cls, dtype: Type[str], align: bool = ..., copy: bool = ...) -> dtype[str_]: ...
@overload
def __new__(cls, dtype: Type[bytes], align: bool = ..., copy: bool = ...) -> dtype[bytes_]: ...
# `unsignedinteger` string-based representations
@overload
def __new__(cls, dtype: _UInt8Codes, align: bool = ..., copy: bool = ...) -> dtype[uint8]: ...
@overload
def __new__(cls, dtype: _UInt16Codes, align: bool = ..., copy: bool = ...) -> dtype[uint16]: ...
@overload
def __new__(cls, dtype: _UInt32Codes, align: bool = ..., copy: bool = ...) -> dtype[uint32]: ...
@overload
def __new__(cls, dtype: _UInt64Codes, align: bool = ..., copy: bool = ...) -> dtype[uint64]: ...
@overload
def __new__(cls, dtype: _UByteCodes, align: bool = ..., copy: bool = ...) -> dtype[ubyte]: ...
@overload
def __new__(cls, dtype: _UShortCodes, align: bool = ..., copy: bool = ...) -> dtype[ushort]: ...
@overload
def __new__(cls, dtype: _UIntCCodes, align: bool = ..., copy: bool = ...) -> dtype[uintc]: ...
@overload
def __new__(cls, dtype: _UIntPCodes, align: bool = ..., copy: bool = ...) -> dtype[uintp]: ...
@overload
def __new__(cls, dtype: _UIntCodes, align: bool = ..., copy: bool = ...) -> dtype[uint]: ...
@overload
def __new__(cls, dtype: _ULongLongCodes, align: bool = ..., copy: bool = ...) -> dtype[ulonglong]: ...
# `signedinteger` string-based representations
@overload
def __new__(cls, dtype: _Int8Codes, align: bool = ..., copy: bool = ...) -> dtype[int8]: ...
@overload
def __new__(cls, dtype: _Int16Codes, align: bool = ..., copy: bool = ...) -> dtype[int16]: ...
@overload
def __new__(cls, dtype: _Int32Codes, align: bool = ..., copy: bool = ...) -> dtype[int32]: ...
@overload
def __new__(cls, dtype: _Int64Codes, align: bool = ..., copy: bool = ...) -> dtype[int64]: ...
@overload
def __new__(cls, dtype: _ByteCodes, align: bool = ..., copy: bool = ...) -> dtype[byte]: ...
@overload
def __new__(cls, dtype: _ShortCodes, align: bool = ..., copy: bool = ...) -> dtype[short]: ...
@overload
def __new__(cls, dtype: _IntCCodes, align: bool = ..., copy: bool = ...) -> dtype[intc]: ...
@overload
def __new__(cls, dtype: _IntPCodes, align: bool = ..., copy: bool = ...) -> dtype[intp]: ...
@overload
def __new__(cls, dtype: _IntCodes, align: bool = ..., copy: bool = ...) -> dtype[int_]: ...
@overload
def __new__(cls, dtype: _LongLongCodes, align: bool = ..., copy: bool = ...) -> dtype[longlong]: ...
# `floating` string-based representations
@overload
def __new__(cls, dtype: _Float16Codes, align: bool = ..., copy: bool = ...) -> dtype[float16]: ...
@overload
def __new__(cls, dtype: _Float32Codes, align: bool = ..., copy: bool = ...) -> dtype[float32]: ...
@overload
def __new__(cls, dtype: _Float64Codes, align: bool = ..., copy: bool = ...) -> dtype[float64]: ...
@overload
def __new__(cls, dtype: _HalfCodes, align: bool = ..., copy: bool = ...) -> dtype[half]: ...
@overload
def __new__(cls, dtype: _SingleCodes, align: bool = ..., copy: bool = ...) -> dtype[single]: ...
@overload
def __new__(cls, dtype: _DoubleCodes, align: bool = ..., copy: bool = ...) -> dtype[double]: ...
@overload
def __new__(cls, dtype: _LongDoubleCodes, align: bool = ..., copy: bool = ...) -> dtype[longdouble]: ...
# `complexfloating` string-based representations
@overload
def __new__(cls, dtype: _Complex64Codes, align: bool = ..., copy: bool = ...) -> dtype[complex64]: ...
@overload
def __new__(cls, dtype: _Complex128Codes, align: bool = ..., copy: bool = ...) -> dtype[complex128]: ...
@overload
def __new__(cls, dtype: _CSingleCodes, align: bool = ..., copy: bool = ...) -> dtype[csingle]: ...
@overload
def __new__(cls, dtype: _CDoubleCodes, align: bool = ..., copy: bool = ...) -> dtype[cdouble]: ...
@overload
def __new__(cls, dtype: _CLongDoubleCodes, align: bool = ..., copy: bool = ...) -> dtype[clongdouble]: ...
# Miscellaneous string-based representations
@overload
def __new__(cls, dtype: _BoolCodes, align: bool = ..., copy: bool = ...) -> dtype[bool_]: ...
@overload
def __new__(cls, dtype: _TD64Codes, align: bool = ..., copy: bool = ...) -> dtype[timedelta64]: ...
@overload
def __new__(cls, dtype: _DT64Codes, align: bool = ..., copy: bool = ...) -> dtype[datetime64]: ...
@overload
def __new__(cls, dtype: _StrCodes, align: bool = ..., copy: bool = ...) -> dtype[str_]: ...
@overload
def __new__(cls, dtype: _BytesCodes, align: bool = ..., copy: bool = ...) -> dtype[bytes_]: ...
@overload
def __new__(cls, dtype: _VoidCodes, align: bool = ..., copy: bool = ...) -> dtype[void]: ...
@overload
def __new__(cls, dtype: _ObjectCodes, align: bool = ..., copy: bool = ...) -> dtype[object_]: ...
# dtype of a dtype is the same dtype
@overload
def __new__(
cls,
dtype: dtype[_DTypeScalar],
align: bool = ...,
copy: bool = ...,
) -> dtype[_DTypeScalar]: ...
# TODO: handle _SupportsDType better
@overload
def __new__(
cls,
dtype: _SupportsDType,
align: bool = ...,
copy: bool = ...,
) -> dtype[Any]: ...
# Handle strings that can't be expressed as literals; i.e. s1, s2, ...
@overload
def __new__(
cls,
dtype: str,
align: bool = ...,
copy: bool = ...,
) -> dtype[Any]: ...
# Catchall overload
@overload
def __new__(
cls,
dtype: _VoidDTypeLike,
align: bool = ...,
copy: bool = ...,
) -> dtype[void]: ...
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) -> _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[Any], int], Tuple[dtype[Any], 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: _DType) -> Optional[Tuple[_DType, _Shape]]: ...
def newbyteorder(self: _DType, __new_order: _ByteOrder = ...) -> _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[_DTypeScalar]: ...
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: ...
_ArrayLikeInt = Union[
int,
integer,
Sequence[Union[int, integer]],
Sequence[Sequence[Any]], # TODO: wait for support for recursive types
ndarray
]
_FlatIterSelf = TypeVar("_FlatIterSelf", bound=flatiter)
class flatiter(Generic[_NdArraySubClass]):
@property
def base(self) -> _NdArraySubClass: ...
@property
def coords(self) -> _Shape: ...
@property
def index(self) -> int: ...
def copy(self) -> _NdArraySubClass: ...
def __iter__(self: _FlatIterSelf) -> _FlatIterSelf: ...
def __next__(self: flatiter[ndarray[Any, dtype[_ScalarType]]]) -> _ScalarType: ...
def __len__(self) -> int: ...
@overload
def __getitem__(
self: flatiter[ndarray[Any, dtype[_ScalarType]]],
key: Union[int, integer],
) -> _ScalarType: ...
@overload
def __getitem__(
self, key: Union[_ArrayLikeInt, slice, ellipsis],
) -> _NdArraySubClass: ...
@overload
def __array__(self: flatiter[ndarray[Any, _DType]], __dtype: None = ...) -> ndarray[Any, _DType]: ...
@overload
def __array__(self, __dtype: DTypeLike) -> ndarray[Any, dtype[Any]]: ...
_OrderKACF = Optional[Literal["K", "A", "C", "F"]]
_OrderACF = Optional[Literal["A", "C", "F"]]
_OrderCF = Optional[Literal["C", "F"]]
_ModeKind = Literal["raise", "wrap", "clip"]
_PartitionKind = Literal["introselect"]
_SortKind = Literal["quicksort", "mergesort", "heapsort", "stable"]
_SortSide = Literal["left", "right"]
_ArrayLikeBool = Union[_BoolLike_co, Sequence[_BoolLike_co], ndarray]
_ArrayLikeIntOrBool = Union[
_IntLike_co,
ndarray,
Sequence[_IntLike_co],
Sequence[Sequence[Any]], # TODO: wait for support for recursive types
]
_ArraySelf = TypeVar("_ArraySelf", bound=_ArrayOrScalarCommon)
class _ArrayOrScalarCommon:
@property
def T(self: _ArraySelf) -> _ArraySelf: ...
@property
def data(self) -> memoryview: ...
@property
def flags(self) -> _flagsobj: ...
@property
def itemsize(self) -> int: ...
@property
def nbytes(self) -> int: ...
def __bool__(self) -> bool: ...
def __bytes__(self) -> bytes: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __copy__(self: _ArraySelf) -> _ArraySelf: ...
def __deepcopy__(self: _ArraySelf, __memo: Optional[dict] = ...) -> _ArraySelf: ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def astype(
self: _ArraySelf,
dtype: DTypeLike,
order: _OrderKACF = ...,
casting: _Casting = ...,
subok: bool = ...,
copy: bool = ...,
) -> _ArraySelf: ...
def copy(self: _ArraySelf, order: _OrderKACF = ...) -> _ArraySelf: ...
def dump(self, file: str) -> None: ...
def dumps(self) -> bytes: ...
def flatten(self, order: _OrderKACF = ...) -> ndarray: ...
def getfield(
self: _ArraySelf, dtype: DTypeLike, offset: int = ...
) -> _ArraySelf: ...
def ravel(self, order: _OrderKACF = ...) -> ndarray: ...
@overload
def reshape(
self, __shape: Sequence[int], *, order: _OrderACF = ...
) -> ndarray: ...
@overload
def reshape(
self, *shape: int, order: _OrderACF = ...
) -> ndarray: ...
def tobytes(self, order: _OrderKACF = ...) -> bytes: ...
# NOTE: `tostring()` is deprecated and therefore excluded
# def tostring(self, order=...): ...
def tofile(
self, fid: Union[IO[bytes], str], sep: str = ..., format: str = ...
) -> None: ...
# generics and 0d arrays return builtin scalars
def tolist(self) -> Any: ...
@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: ...
# TODO: Add proper signatures
def __getitem__(self, key) -> Any: ...
@property
def __array_interface__(self): ...
@property
def __array_priority__(self): ...
@property
def __array_struct__(self): ...
def __array_wrap__(array, context=...): ...
def __setstate__(self, __state): ...
# a `bool_` is returned when `keepdims=True` and `self` is a 0d array
@overload
def all(
self, axis: None = ..., out: None = ..., keepdims: Literal[False] = ...
) -> bool_: ...
@overload
def all(
self, axis: Optional[_ShapeLike] = ..., out: None = ..., keepdims: bool = ...
) -> Union[bool_, ndarray]: ...
@overload
def all(
self,
axis: Optional[_ShapeLike] = ...,
out: _NdArraySubClass = ...,
keepdims: bool = ...,
) -> _NdArraySubClass: ...
@overload
def any(
self, axis: None = ..., out: None = ..., keepdims: Literal[False] = ...
) -> bool_: ...
@overload
def any(
self, axis: Optional[_ShapeLike] = ..., out: None = ..., keepdims: bool = ...
) -> Union[bool_, ndarray]: ...
@overload
def any(
self,
axis: Optional[_ShapeLike] = ...,
out: _NdArraySubClass = ...,
keepdims: bool = ...,
) -> _NdArraySubClass: ...
@overload
def argmax(self, axis: None = ..., out: None = ...) -> intp: ...
@overload
def argmax(
self, axis: _ShapeLike = ..., out: None = ...
) -> Union[ndarray, intp]: ...
@overload
def argmax(
self, axis: Optional[_ShapeLike] = ..., out: _NdArraySubClass = ...
) -> _NdArraySubClass: ...
@overload
def argmin(self, axis: None = ..., out: None = ...) -> intp: ...
@overload
def argmin(
self, axis: _ShapeLike = ..., out: None = ...
) -> Union[ndarray, intp]: ...
@overload
def argmin(
self, axis: Optional[_ShapeLike] = ..., out: _NdArraySubClass = ...
) -> _NdArraySubClass: ...
def argsort(
self,
axis: Optional[int] = ...,
kind: Optional[_SortKind] = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> ndarray: ...
@overload
def choose(
self, choices: ArrayLike, out: None = ..., mode: _ModeKind = ...,
) -> ndarray: ...
@overload
def choose(
self, choices: ArrayLike, out: _NdArraySubClass = ..., mode: _ModeKind = ...,
) -> _NdArraySubClass: ...
@overload
def clip(
self,
min: ArrayLike = ...,
max: Optional[ArrayLike] = ...,
out: None = ...,
**kwargs: Any,
) -> Union[number, ndarray]: ...
@overload
def clip(
self,
min: None = ...,
max: ArrayLike = ...,
out: None = ...,
**kwargs: Any,
) -> Union[number, ndarray]: ...
@overload
def clip(
self,
min: ArrayLike = ...,
max: Optional[ArrayLike] = ...,
out: _NdArraySubClass = ...,
**kwargs: Any,
) -> _NdArraySubClass: ...
@overload
def clip(
self,
min: None = ...,
max: ArrayLike = ...,
out: _NdArraySubClass = ...,
**kwargs: Any,
) -> _NdArraySubClass: ...
@overload
def compress(
self, a: ArrayLike, axis: Optional[int] = ..., out: None = ...,
) -> ndarray: ...
@overload
def compress(
self, a: ArrayLike, axis: Optional[int] = ..., out: _NdArraySubClass = ...,
) -> _NdArraySubClass: ...
def conj(self: _ArraySelf) -> _ArraySelf: ...
def conjugate(self: _ArraySelf) -> _ArraySelf: ...
@overload
def cumprod(
self, axis: Optional[int] = ..., dtype: DTypeLike = ..., out: None = ...,
) -> ndarray: ...
@overload
def cumprod(
self,
axis: Optional[int] = ...,
dtype: DTypeLike = ...,
out: _NdArraySubClass = ...,
) -> _NdArraySubClass: ...
@overload
def cumsum(
self, axis: Optional[int] = ..., dtype: DTypeLike = ..., out: None = ...,
) -> ndarray: ...
@overload
def cumsum(
self,
axis: Optional[int] = ...,
dtype: DTypeLike = ...,
out: _NdArraySubClass = ...,
) -> _NdArraySubClass: ...
@overload
def max(
self,
axis: None = ...,
out: None = ...,
keepdims: Literal[False] = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> number: ...
@overload
def max(
self,
axis: Optional[_ShapeLike] = ...,
out: None = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> Union[number, ndarray]: ...
@overload
def max(
self,
axis: Optional[_ShapeLike] = ...,
out: _NdArraySubClass = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> _NdArraySubClass: ...
@overload
def mean(
self,
axis: None = ...,
dtype: DTypeLike = ...,
out: None = ...,
keepdims: Literal[False] = ...,
) -> number: ...
@overload
def mean(
self,
axis: Optional[_ShapeLike] = ...,
dtype: DTypeLike = ...,
out: None = ...,
keepdims: bool = ...,
) -> Union[number, ndarray]: ...
@overload
def mean(
self,
axis: Optional[_ShapeLike] = ...,
dtype: DTypeLike = ...,
out: _NdArraySubClass = ...,
keepdims: bool = ...,
) -> _NdArraySubClass: ...
@overload
def min(
self,
axis: None = ...,
out: None = ...,
keepdims: Literal[False] = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> number: ...
@overload
def min(
self,
axis: Optional[_ShapeLike] = ...,
out: None = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> Union[number, ndarray]: ...
@overload
def min(
self,
axis: Optional[_ShapeLike] = ...,
out: _NdArraySubClass = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> _NdArraySubClass: ...
def newbyteorder(self: _ArraySelf, __new_order: _ByteOrder = ...) -> _ArraySelf: ...
@overload
def prod(
self,
axis: None = ...,
dtype: DTypeLike = ...,
out: None = ...,
keepdims: Literal[False] = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> number: ...
@overload
def prod(
self,
axis: Optional[_ShapeLike] = ...,
dtype: DTypeLike = ...,
out: None = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> Union[number, ndarray]: ...
@overload
def prod(
self,
axis: Optional[_ShapeLike] = ...,
dtype: DTypeLike = ...,
out: _NdArraySubClass = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> _NdArraySubClass: ...
@overload
def ptp(
self, axis: None = ..., out: None = ..., keepdims: Literal[False] = ...,
) -> number: ...
@overload
def ptp(
self, axis: Optional[_ShapeLike] = ..., out: None = ..., keepdims: bool = ...,
) -> Union[number, ndarray]: ...
@overload
def ptp(
self,
axis: Optional[_ShapeLike] = ...,
out: _NdArraySubClass = ...,
keepdims: bool = ...,
) -> _NdArraySubClass: ...
def repeat(
self, repeats: _ArrayLikeIntOrBool, axis: Optional[int] = ...
) -> ndarray: ...
@overload
def round(self: _ArraySelf, decimals: int = ..., out: None = ...) -> _ArraySelf: ...
@overload
def round(
self, decimals: int = ..., out: _NdArraySubClass = ...
) -> _NdArraySubClass: ...
@overload
def std(
self,
axis: None = ...,
dtype: DTypeLike = ...,
out: None = ...,
ddof: int = ...,
keepdims: Literal[False] = ...,
) -> number: ...
@overload
def std(
self,
axis: Optional[_ShapeLike] = ...,
dtype: DTypeLike = ...,
out: None = ...,
ddof: int = ...,
keepdims: bool = ...,
) -> Union[number, ndarray]: ...
@overload
def std(
self,
axis: Optional[_ShapeLike] = ...,
dtype: DTypeLike = ...,
out: _NdArraySubClass = ...,
ddof: int = ...,
keepdims: bool = ...,
) -> _NdArraySubClass: ...
@overload
def sum(
self,
axis: None = ...,
dtype: DTypeLike = ...,
out: None = ...,
keepdims: Literal[False] = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> number: ...
@overload
def sum(
self,
axis: Optional[_ShapeLike] = ...,
dtype: DTypeLike = ...,
out: None = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> Union[number, ndarray]: ...
@overload
def sum(
self,
axis: Optional[_ShapeLike] = ...,
dtype: DTypeLike = ...,
out: _NdArraySubClass = ...,
keepdims: bool = ...,
initial: _NumberLike_co = ...,
where: _ArrayLikeBool = ...,
) -> _NdArraySubClass: ...
@overload
def take(
self,
indices: _IntLike_co,
axis: Optional[int] = ...,
out: None = ...,
mode: _ModeKind = ...,
) -> generic: ...
@overload
def take(
self,
indices: _ArrayLikeIntOrBool,
axis: Optional[int] = ...,
out: None = ...,
mode: _ModeKind = ...,
) -> ndarray: ...
@overload
def take(
self,
indices: _ArrayLikeIntOrBool,
axis: Optional[int] = ...,
out: _NdArraySubClass = ...,
mode: _ModeKind = ...,
) -> _NdArraySubClass: ...
@overload
def var(
self,
axis: None = ...,
dtype: DTypeLike = ...,
out: None = ...,
ddof: int = ...,
keepdims: Literal[False] = ...,
) -> number: ...
@overload
def var(
self,
axis: Optional[_ShapeLike] = ...,
dtype: DTypeLike = ...,
out: None = ...,
ddof: int = ...,
keepdims: bool = ...,
) -> Union[number, ndarray]: ...
@overload
def var(
self,
axis: Optional[_ShapeLike] = ...,
dtype: DTypeLike = ...,
out: _NdArraySubClass = ...,
ddof: int = ...,
keepdims: bool = ...,
) -> _NdArraySubClass: ...
_DType = TypeVar("_DType", bound=dtype[Any])
# TODO: Set the `bound` to something more suitable once we
# have proper shape support
_ShapeType = TypeVar("_ShapeType", bound=Any)
_BufferType = Union[ndarray, bytes, bytearray, memoryview]
_Casting = Literal["no", "equiv", "safe", "same_kind", "unsafe"]
class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType]):
@property
def base(self) -> Optional[ndarray]: ...
@property
def ndim(self) -> int: ...
@property
def size(self) -> int: ...
@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: _OrderKACF = ...,
) -> _ArraySelf: ...
@overload
def __array__(self, __dtype: None = ...) -> ndarray[Any, _DType]: ...
@overload
def __array__(self, __dtype: DTypeLike) -> ndarray[Any, dtype[Any]]: ...
@property
def ctypes(self) -> _ctypes: ...
@property
def shape(self) -> _Shape: ...
@shape.setter
def shape(self, value: _ShapeLike): ...
@property
def strides(self) -> _Shape: ...
@strides.setter
def strides(self, value: _ShapeLike): ...
def byteswap(self: _ArraySelf, inplace: bool = ...) -> _ArraySelf: ...
def fill(self, value: Any) -> None: ...
@property
def flat(self: _NdArraySubClass) -> flatiter[_NdArraySubClass]: ...
@overload
def item(self, *args: int) -> Any: ...
@overload
def item(self, __args: Tuple[int, ...]) -> Any: ...
@overload
def itemset(self, __value: Any) -> None: ...
@overload
def itemset(self, __item: _ShapeLike, __value: Any) -> None: ...
@overload
def resize(self, __new_shape: Sequence[int], *, refcheck: bool = ...) -> None: ...
@overload
def resize(self, *new_shape: int, refcheck: bool = ...) -> None: ...
def setflags(
self, write: bool = ..., align: bool = ..., uic: bool = ...
) -> None: ...
def squeeze(
self: _ArraySelf, axis: Union[int, Tuple[int, ...]] = ...
) -> _ArraySelf: ...
def swapaxes(self: _ArraySelf, axis1: int, axis2: int) -> _ArraySelf: ...
@overload
def transpose(self: _ArraySelf, __axes: Sequence[int]) -> _ArraySelf: ...
@overload
def transpose(self: _ArraySelf, *axes: int) -> _ArraySelf: ...
def argpartition(
self,
kth: _ArrayLikeIntOrBool,
axis: Optional[int] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> ndarray: ...
def diagonal(
self: _ArraySelf, offset: int = ..., axis1: int = ..., axis2: int = ...
) -> _ArraySelf: ...
@overload
def dot(self, b: ArrayLike, out: None = ...) -> Union[number, ndarray]: ...
@overload
def dot(self, b: ArrayLike, out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
# `nonzero()` is deprecated for 0d arrays/generics
def nonzero(self) -> Tuple[ndarray, ...]: ...
def partition(
self,
kth: _ArrayLikeIntOrBool,
axis: int = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> None: ...
# `put` is technically available to `generic`,
# but is pointless as `generic`s are immutable
def put(
self, ind: _ArrayLikeIntOrBool, v: ArrayLike, mode: _ModeKind = ...
) -> None: ...
def searchsorted(
self, # >= 1D array
v: ArrayLike,
side: _SortSide = ...,
sorter: Optional[_ArrayLikeIntOrBool] = ..., # 1D int array
) -> ndarray: ...
def setfield(
self, val: ArrayLike, dtype: DTypeLike, offset: int = ...
) -> None: ...
def sort(
self,
axis: int = ...,
kind: Optional[_SortKind] = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> None: ...
@overload
def trace(
self, # >= 2D array
offset: int = ...,
axis1: int = ...,
axis2: int = ...,
dtype: DTypeLike = ...,
out: None = ...,
) -> Union[number, ndarray]: ...
@overload
def trace(
self, # >= 2D array
offset: int = ...,
axis1: int = ...,
axis2: int = ...,
dtype: DTypeLike = ...,
out: _NdArraySubClass = ...,
) -> _NdArraySubClass: ...
# 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 __int__(self) -> int: ...
def __float__(self) -> float: ...
def __complex__(self) -> complex: ...
def __len__(self) -> int: ...
def __setitem__(self, key, value): ...
def __iter__(self) -> Any: ...
def __contains__(self, key) -> bool: ...
def __index__(self) -> int: ...
def __lt__(self, other: ArrayLike) -> Union[ndarray, bool_]: ...
def __le__(self, other: ArrayLike) -> Union[ndarray, bool_]: ...
def __gt__(self, other: ArrayLike) -> Union[ndarray, bool_]: ...
def __ge__(self, other: ArrayLike) -> Union[ndarray, bool_]: ...
def __matmul__(self, other: ArrayLike) -> Any: ...
# NOTE: `ndarray` does not implement `__imatmul__`
def __rmatmul__(self, other: ArrayLike) -> Any: ...
def __neg__(self: _ArraySelf) -> Any: ...
def __pos__(self: _ArraySelf) -> Any: ...
def __abs__(self: _ArraySelf) -> Any: ...
def __mod__(self, other: ArrayLike) -> Any: ...
def __rmod__(self, other: ArrayLike) -> Any: ...
def __divmod__(self, other: ArrayLike) -> Tuple[Any, Any]: ...
def __rdivmod__(self, other: ArrayLike) -> Tuple[Any, Any]: ...
def __add__(self, other: ArrayLike) -> Any: ...
def __radd__(self, other: ArrayLike) -> Any: ...
def __sub__(self, other: ArrayLike) -> Any: ...
def __rsub__(self, other: ArrayLike) -> Any: ...
def __mul__(self, other: ArrayLike) -> Any: ...
def __rmul__(self, other: ArrayLike) -> Any: ...
def __floordiv__(self, other: ArrayLike) -> Any: ...
def __rfloordiv__(self, other: ArrayLike) -> Any: ...
def __pow__(self, other: ArrayLike) -> Any: ...
def __rpow__(self, other: ArrayLike) -> Any: ...
def __truediv__(self, other: ArrayLike) -> Any: ...
def __rtruediv__(self, other: ArrayLike) -> Any: ...
def __invert__(self: _ArraySelf) -> Any: ...
def __lshift__(self, other: ArrayLike) -> Any: ...
def __rlshift__(self, other: ArrayLike) -> Any: ...
def __rshift__(self, other: ArrayLike) -> Any: ...
def __rrshift__(self, other: ArrayLike) -> Any: ...
def __and__(self, other: ArrayLike) -> Any: ...
def __rand__(self, other: ArrayLike) -> Any: ...
def __xor__(self, other: ArrayLike) -> Any: ...
def __rxor__(self, other: ArrayLike) -> Any: ...
def __or__(self, other: ArrayLike) -> Any: ...
def __ror__(self, other: ArrayLike) -> Any: ...
# `np.generic` does not support inplace operations
def __iadd__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
def __isub__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
def __imul__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
def __itruediv__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
def __ifloordiv__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
def __ipow__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
def __imod__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
def __ilshift__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
def __irshift__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
def __iand__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
def __ixor__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
def __ior__(self: _ArraySelf, other: ArrayLike) -> _ArraySelf: ...
# Keep `dtype` at the bottom to avoid name conflicts with `np.dtype`
@property
def dtype(self) -> _DType: ...
# 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.
_ScalarType = TypeVar("_ScalarType", bound=generic)
_NBit_co = TypeVar("_NBit_co", covariant=True, bound=NBitBase)
_NBit_co2 = TypeVar("_NBit_co2", covariant=True, bound=NBitBase)
class generic(_ArrayOrScalarCommon):
@abstractmethod
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@overload
def __array__(self: _ScalarType, __dtype: None = ...) -> ndarray[Any, dtype[_ScalarType]]: ...
@overload
def __array__(self, __dtype: DTypeLike) -> ndarray[Any, dtype[Any]]: ...
@property
def base(self) -> None: ...
@property
def ndim(self) -> Literal[0]: ...
@property
def size(self) -> Literal[1]: ...
@property
def shape(self) -> Tuple[()]: ...
@property
def strides(self) -> Tuple[()]: ...
def byteswap(self: _ScalarType, inplace: Literal[False] = ...) -> _ScalarType: ...
@property
def flat(self: _ScalarType) -> flatiter[ndarray[Any, dtype[_ScalarType]]]: ...
def item(
self: _ScalarType,
__args: Union[Literal[0], Tuple[()], Tuple[Literal[0]]] = ...,
) -> Any: ...
def squeeze(
self: _ScalarType, axis: Union[Literal[0], Tuple[()]] = ...
) -> _ScalarType: ...
def transpose(self: _ScalarType, __axes: Tuple[()] = ...) -> _ScalarType: ...
# Keep `dtype` at the bottom to avoid name conflicts with `np.dtype`
@property
def dtype(self: _ScalarType) -> dtype[_ScalarType]: ...
class number(generic, Generic[_NBit_co]): # type: ignore
@property
def real(self: _ArraySelf) -> _ArraySelf: ...
@property
def imag(self: _ArraySelf) -> _ArraySelf: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __complex__(self) -> complex: ...
def __neg__(self: _ArraySelf) -> _ArraySelf: ...
def __pos__(self: _ArraySelf) -> _ArraySelf: ...
def __abs__(self: _ArraySelf) -> _ArraySelf: ...
# Ensure that objects annotated as `number` support arithmetic operations
__add__: _NumberOp
__radd__: _NumberOp
__sub__: _NumberOp
__rsub__: _NumberOp
__mul__: _NumberOp
__rmul__: _NumberOp
__floordiv__: _NumberOp
__rfloordiv__: _NumberOp
__pow__: _NumberOp
__rpow__: _NumberOp
__truediv__: _NumberOp
__rtruediv__: _NumberOp
__lt__: _ComparisonOp[_NumberLike_co]
__le__: _ComparisonOp[_NumberLike_co]
__gt__: _ComparisonOp[_NumberLike_co]
__ge__: _ComparisonOp[_NumberLike_co]
class bool_(generic):
def __init__(self, __value: object = ...) -> None: ...
@property
def real(self: _ArraySelf) -> _ArraySelf: ...
@property
def imag(self: _ArraySelf) -> _ArraySelf: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __complex__(self) -> complex: ...
def __abs__(self: _ArraySelf) -> _ArraySelf: ...
__add__: _BoolOp[bool_]
__radd__: _BoolOp[bool_]
__sub__: _BoolSub
__rsub__: _BoolSub
__mul__: _BoolOp[bool_]
__rmul__: _BoolOp[bool_]
__floordiv__: _BoolOp[int8]
__rfloordiv__: _BoolOp[int8]
__pow__: _BoolOp[int8]
__rpow__: _BoolOp[int8]
__truediv__: _BoolTrueDiv
__rtruediv__: _BoolTrueDiv
def __invert__(self) -> bool_: ...
__lshift__: _BoolBitOp[int8]
__rlshift__: _BoolBitOp[int8]
__rshift__: _BoolBitOp[int8]
__rrshift__: _BoolBitOp[int8]
__and__: _BoolBitOp[bool_]
__rand__: _BoolBitOp[bool_]
__xor__: _BoolBitOp[bool_]
__rxor__: _BoolBitOp[bool_]
__or__: _BoolBitOp[bool_]
__ror__: _BoolBitOp[bool_]
__mod__: _BoolMod
__rmod__: _BoolMod
__divmod__: _BoolDivMod
__rdivmod__: _BoolDivMod
__lt__: _ComparisonOp[_NumberLike_co]
__le__: _ComparisonOp[_NumberLike_co]
__gt__: _ComparisonOp[_NumberLike_co]
__ge__: _ComparisonOp[_NumberLike_co]
class object_(generic):
def __init__(self, __value: object = ...) -> None: ...
@property
def real(self: _ArraySelf) -> _ArraySelf: ...
@property
def imag(self: _ArraySelf) -> _ArraySelf: ...
class datetime64(generic):
@overload
def __init__(
self,
__value: Union[None, datetime64, _CharLike_co, dt.datetime] = ...,
__format: Union[_CharLike_co, Tuple[_CharLike_co, _IntLike_co]] = ...,
) -> None: ...
@overload
def __init__(
self,
__value: int,
__format: Union[_CharLike_co, Tuple[_CharLike_co, _IntLike_co]]
) -> None: ...
def __add__(self, other: _TD64Like_co) -> datetime64: ...
def __radd__(self, other: _TD64Like_co) -> datetime64: ...
@overload
def __sub__(self, other: datetime64) -> timedelta64: ...
@overload
def __sub__(self, other: _TD64Like_co) -> datetime64: ...
def __rsub__(self, other: datetime64) -> timedelta64: ...
__lt__: _ComparisonOp[datetime64]
__le__: _ComparisonOp[datetime64]
__gt__: _ComparisonOp[datetime64]
__ge__: _ComparisonOp[datetime64]
# Support for `__index__` was added in python 3.8 (bpo-20092)
if sys.version_info >= (3, 8):
_IntValue = Union[SupportsInt, _CharLike_co, SupportsIndex]
_FloatValue = Union[None, _CharLike_co, SupportsFloat, SupportsIndex]
_ComplexValue = Union[None, _CharLike_co, SupportsFloat, SupportsComplex, SupportsIndex]
else:
_IntValue = Union[SupportsInt, _CharLike_co]
_FloatValue = Union[None, _CharLike_co, SupportsFloat]
_ComplexValue = Union[None, _CharLike_co, SupportsFloat, SupportsComplex]
class integer(number[_NBit_co]): # type: ignore
# NOTE: `__index__` is technically defined in the bottom-most
# sub-classes (`int64`, `uint32`, etc)
def __index__(self) -> int: ...
__truediv__: _IntTrueDiv[_NBit_co]
__rtruediv__: _IntTrueDiv[_NBit_co]
def __mod__(self, value: _IntLike_co) -> integer: ...
def __rmod__(self, value: _IntLike_co) -> integer: ...
def __invert__(self: _IntType) -> _IntType: ...
# Ensure that objects annotated as `integer` support bit-wise operations
def __lshift__(self, other: _IntLike_co) -> integer: ...
def __rlshift__(self, other: _IntLike_co) -> integer: ...
def __rshift__(self, other: _IntLike_co) -> integer: ...
def __rrshift__(self, other: _IntLike_co) -> integer: ...
def __and__(self, other: _IntLike_co) -> integer: ...
def __rand__(self, other: _IntLike_co) -> integer: ...
def __or__(self, other: _IntLike_co) -> integer: ...
def __ror__(self, other: _IntLike_co) -> integer: ...
def __xor__(self, other: _IntLike_co) -> integer: ...
def __rxor__(self, other: _IntLike_co) -> integer: ...
class signedinteger(integer[_NBit_co]):
def __init__(self, __value: _IntValue = ...) -> None: ...
__add__: _SignedIntOp[_NBit_co]
__radd__: _SignedIntOp[_NBit_co]
__sub__: _SignedIntOp[_NBit_co]
__rsub__: _SignedIntOp[_NBit_co]
__mul__: _SignedIntOp[_NBit_co]
__rmul__: _SignedIntOp[_NBit_co]
__floordiv__: _SignedIntOp[_NBit_co]
__rfloordiv__: _SignedIntOp[_NBit_co]
__pow__: _SignedIntOp[_NBit_co]
__rpow__: _SignedIntOp[_NBit_co]
__lshift__: _SignedIntBitOp[_NBit_co]
__rlshift__: _SignedIntBitOp[_NBit_co]
__rshift__: _SignedIntBitOp[_NBit_co]
__rrshift__: _SignedIntBitOp[_NBit_co]
__and__: _SignedIntBitOp[_NBit_co]
__rand__: _SignedIntBitOp[_NBit_co]
__xor__: _SignedIntBitOp[_NBit_co]
__rxor__: _SignedIntBitOp[_NBit_co]
__or__: _SignedIntBitOp[_NBit_co]
__ror__: _SignedIntBitOp[_NBit_co]
__mod__: _SignedIntMod[_NBit_co]
__rmod__: _SignedIntMod[_NBit_co]
__divmod__: _SignedIntDivMod[_NBit_co]
__rdivmod__: _SignedIntDivMod[_NBit_co]
int8 = signedinteger[_8Bit]
int16 = signedinteger[_16Bit]
int32 = signedinteger[_32Bit]
int64 = signedinteger[_64Bit]
byte = signedinteger[_NBitByte]
short = signedinteger[_NBitShort]
intc = signedinteger[_NBitIntC]
intp = signedinteger[_NBitIntP]
int0 = signedinteger[_NBitIntP]
int_ = signedinteger[_NBitInt]
longlong = signedinteger[_NBitLongLong]
class timedelta64(generic):
def __init__(
self,
__value: Union[None, int, _CharLike_co, dt.timedelta, timedelta64] = ...,
__format: Union[_CharLike_co, Tuple[_CharLike_co, _IntLike_co]] = ...,
) -> None: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __complex__(self) -> complex: ...
def __neg__(self: _ArraySelf) -> _ArraySelf: ...
def __pos__(self: _ArraySelf) -> _ArraySelf: ...
def __abs__(self: _ArraySelf) -> _ArraySelf: ...
def __add__(self, other: _TD64Like_co) -> timedelta64: ...
def __radd__(self, other: _TD64Like_co) -> timedelta64: ...
def __sub__(self, other: _TD64Like_co) -> timedelta64: ...
def __rsub__(self, other: _TD64Like_co) -> timedelta64: ...
def __mul__(self, other: _FloatLike_co) -> timedelta64: ...
def __rmul__(self, other: _FloatLike_co) -> timedelta64: ...
__truediv__: _TD64Div[float64]
__floordiv__: _TD64Div[int64]
def __rtruediv__(self, other: timedelta64) -> float64: ...
def __rfloordiv__(self, other: timedelta64) -> int64: ...
def __mod__(self, other: timedelta64) -> timedelta64: ...
def __rmod__(self, other: timedelta64) -> timedelta64: ...
def __divmod__(self, other: timedelta64) -> Tuple[int64, timedelta64]: ...
def __rdivmod__(self, other: timedelta64) -> Tuple[int64, timedelta64]: ...
__lt__: _ComparisonOp[Union[timedelta64, _IntLike_co, _BoolLike_co]]
__le__: _ComparisonOp[Union[timedelta64, _IntLike_co, _BoolLike_co]]
__gt__: _ComparisonOp[Union[timedelta64, _IntLike_co, _BoolLike_co]]
__ge__: _ComparisonOp[Union[timedelta64, _IntLike_co, _BoolLike_co]]
class unsignedinteger(integer[_NBit_co]):
# NOTE: `uint64 + signedinteger -> float64`
def __init__(self, __value: _IntValue = ...) -> None: ...
__add__: _UnsignedIntOp[_NBit_co]
__radd__: _UnsignedIntOp[_NBit_co]
__sub__: _UnsignedIntOp[_NBit_co]
__rsub__: _UnsignedIntOp[_NBit_co]
__mul__: _UnsignedIntOp[_NBit_co]
__rmul__: _UnsignedIntOp[_NBit_co]
__floordiv__: _UnsignedIntOp[_NBit_co]
__rfloordiv__: _UnsignedIntOp[_NBit_co]
__pow__: _UnsignedIntOp[_NBit_co]
__rpow__: _UnsignedIntOp[_NBit_co]
__lshift__: _UnsignedIntBitOp[_NBit_co]
__rlshift__: _UnsignedIntBitOp[_NBit_co]
__rshift__: _UnsignedIntBitOp[_NBit_co]
__rrshift__: _UnsignedIntBitOp[_NBit_co]
__and__: _UnsignedIntBitOp[_NBit_co]
__rand__: _UnsignedIntBitOp[_NBit_co]
__xor__: _UnsignedIntBitOp[_NBit_co]
__rxor__: _UnsignedIntBitOp[_NBit_co]
__or__: _UnsignedIntBitOp[_NBit_co]
__ror__: _UnsignedIntBitOp[_NBit_co]
__mod__: _UnsignedIntMod[_NBit_co]
__rmod__: _UnsignedIntMod[_NBit_co]
__divmod__: _UnsignedIntDivMod[_NBit_co]
__rdivmod__: _UnsignedIntDivMod[_NBit_co]
uint8 = unsignedinteger[_8Bit]
uint16 = unsignedinteger[_16Bit]
uint32 = unsignedinteger[_32Bit]
uint64 = unsignedinteger[_64Bit]
ubyte = unsignedinteger[_NBitByte]
ushort = unsignedinteger[_NBitShort]
uintc = unsignedinteger[_NBitIntC]
uintp = unsignedinteger[_NBitIntP]
uint0 = unsignedinteger[_NBitIntP]
uint = unsignedinteger[_NBitInt]
ulonglong = unsignedinteger[_NBitLongLong]
class inexact(number[_NBit_co]): ... # type: ignore
_IntType = TypeVar("_IntType", bound=integer)
_FloatType = TypeVar('_FloatType', bound=floating)
class floating(inexact[_NBit_co]):
def __init__(self, __value: _FloatValue = ...) -> None: ...
__add__: _FloatOp[_NBit_co]
__radd__: _FloatOp[_NBit_co]
__sub__: _FloatOp[_NBit_co]
__rsub__: _FloatOp[_NBit_co]
__mul__: _FloatOp[_NBit_co]
__rmul__: _FloatOp[_NBit_co]
__truediv__: _FloatOp[_NBit_co]
__rtruediv__: _FloatOp[_NBit_co]
__floordiv__: _FloatOp[_NBit_co]
__rfloordiv__: _FloatOp[_NBit_co]
__pow__: _FloatOp[_NBit_co]
__rpow__: _FloatOp[_NBit_co]
__mod__: _FloatMod[_NBit_co]
__rmod__: _FloatMod[_NBit_co]
__divmod__: _FloatDivMod[_NBit_co]
__rdivmod__: _FloatDivMod[_NBit_co]
float16 = floating[_16Bit]
float32 = floating[_32Bit]
float64 = floating[_64Bit]
half = floating[_NBitHalf]
single = floating[_NBitSingle]
double = floating[_NBitDouble]
float_ = floating[_NBitDouble]
longdouble = floating[_NBitLongDouble]
longfloat = floating[_NBitLongDouble]
# The main reason for `complexfloating` having two typevars is cosmetic.
# It is used to clarify why `complex128`s precision is `_64Bit`, the latter
# describing the two 64 bit floats representing its real and imaginary component
class complexfloating(inexact[_NBit_co], Generic[_NBit_co, _NBit_co2]):
def __init__(self, __value: _ComplexValue = ...) -> None: ...
@property
def real(self) -> floating[_NBit_co]: ... # type: ignore[override]
@property
def imag(self) -> floating[_NBit_co2]: ... # type: ignore[override]
def __abs__(self) -> floating[_NBit_co]: ... # type: ignore[override]
__add__: _ComplexOp[_NBit_co]
__radd__: _ComplexOp[_NBit_co]
__sub__: _ComplexOp[_NBit_co]
__rsub__: _ComplexOp[_NBit_co]
__mul__: _ComplexOp[_NBit_co]
__rmul__: _ComplexOp[_NBit_co]
__truediv__: _ComplexOp[_NBit_co]
__rtruediv__: _ComplexOp[_NBit_co]
__floordiv__: _ComplexOp[_NBit_co]
__rfloordiv__: _ComplexOp[_NBit_co]
__pow__: _ComplexOp[_NBit_co]
__rpow__: _ComplexOp[_NBit_co]
complex64 = complexfloating[_32Bit, _32Bit]
complex128 = complexfloating[_64Bit, _64Bit]
csingle = complexfloating[_NBitSingle, _NBitSingle]
singlecomplex = complexfloating[_NBitSingle, _NBitSingle]
cdouble = complexfloating[_NBitDouble, _NBitDouble]
complex_ = complexfloating[_NBitDouble, _NBitDouble]
cfloat = complexfloating[_NBitDouble, _NBitDouble]
clongdouble = complexfloating[_NBitLongDouble, _NBitLongDouble]
clongfloat = complexfloating[_NBitLongDouble, _NBitLongDouble]
longcomplex = complexfloating[_NBitLongDouble, _NBitLongDouble]
class flexible(generic): ... # type: ignore
class void(flexible):
def __init__(self, __value: Union[_IntLike_co, bytes]): ...
@property
def real(self: _ArraySelf) -> _ArraySelf: ...
@property
def imag(self: _ArraySelf) -> _ArraySelf: ...
def setfield(
self, val: ArrayLike, dtype: DTypeLike, offset: int = ...
) -> None: ...
class character(flexible): # type: ignore
def __int__(self) -> int: ...
def __float__(self) -> float: ...
# NOTE: Most `np.bytes_` / `np.str_` methods return their
# builtin `bytes` / `str` counterpart
class bytes_(character, bytes):
@overload
def __init__(self, __value: object = ...) -> None: ...
@overload
def __init__(
self, __value: str, encoding: str = ..., errors: str = ...
) -> None: ...
class str_(character, str):
@overload
def __init__(self, __value: object = ...) -> None: ...
@overload
def __init__(
self, __value: bytes, encoding: str = ..., errors: str = ...
) -> None: ...
unicode_ = str_
str0 = str_
# TODO: Platform dependent types: float128, complex256, float96
def array(
object: object,
dtype: DTypeLike = ...,
*,
copy: bool = ...,
order: _OrderKACF = ...,
subok: bool = ...,
ndmin: int = ...,
like: ArrayLike = ...,
) -> ndarray: ...
def zeros(
shape: _ShapeLike,
dtype: DTypeLike = ...,
order: _OrderCF = ...,
*,
like: ArrayLike = ...,
) -> ndarray: ...
def empty(
shape: _ShapeLike,
dtype: DTypeLike = ...,
order: _OrderCF = ...,
*,
like: ArrayLike = ...,
) -> ndarray: ...
def broadcast_shapes(*args: _ShapeLike) -> _Shape: ...
#
# Constants
#
Inf: Final[float]
Infinity: Final[float]
NAN: Final[float]
NINF: Final[float]
NZERO: Final[float]
NaN: Final[float]
PINF: Final[float]
PZERO: Final[float]
e: Final[float]
euler_gamma: Final[float]
inf: Final[float]
infty: Final[float]
nan: Final[float]
pi: Final[float]
ALLOW_THREADS: Final[int]
BUFSIZE: Final[int]
CLIP: Final[int]
ERR_CALL: Final[int]
ERR_DEFAULT: Final[int]
ERR_IGNORE: Final[int]
ERR_LOG: Final[int]
ERR_PRINT: Final[int]
ERR_RAISE: Final[int]
ERR_WARN: Final[int]
FLOATING_POINT_SUPPORT: Final[int]
FPE_DIVIDEBYZERO: Final[int]
FPE_INVALID: Final[int]
FPE_OVERFLOW: Final[int]
FPE_UNDERFLOW: Final[int]
MAXDIMS: Final[int]
MAY_SHARE_BOUNDS: Final[int]
MAY_SHARE_EXACT: Final[int]
RAISE: Final[int]
SHIFT_DIVIDEBYZERO: Final[int]
SHIFT_INVALID: Final[int]
SHIFT_OVERFLOW: Final[int]
SHIFT_UNDERFLOW: Final[int]
UFUNC_BUFSIZE_DEFAULT: Final[int]
WRAP: Final[int]
tracemalloc_domain: Final[int]
little_endian: Final[bool]
True_: Final[bool_]
False_: Final[bool_]
UFUNC_PYVALS_NAME: Final[str]
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 = ...,
casting: _Casting = ...,
order: _OrderKACF = ...,
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]] = ...,
) -> Any: ...
@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
abs = absolute
# 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: ...
_CallType = TypeVar("_CallType", bound=Union[_ErrFunc, _SupportsWrite])
class errstate(Generic[_CallType], ContextDecorator):
call: _CallType
kwargs: _ErrDictOptional
# Expand `**kwargs` into explicit keyword-only arguments
def __init__(
self,
*,
call: _CallType = ...,
all: Optional[_ErrKind] = ...,
divide: Optional[_ErrKind] = ...,
over: Optional[_ErrKind] = ...,
under: Optional[_ErrKind] = ...,
invalid: Optional[_ErrKind] = ...,
) -> None: ...
def __enter__(self) -> None: ...
def __exit__(
self,
__exc_type: Optional[Type[BaseException]],
__exc_value: Optional[BaseException],
__traceback: Optional[TracebackType],
) -> None: ...
|