-
-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Expand file tree
/
Copy path__init__.pyi
More file actions
7680 lines (7183 loc) · 278 KB
/
__init__.pyi
File metadata and controls
7680 lines (7183 loc) · 278 KB
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
# ruff: noqa: I001
import ctypes as ct
import datetime as dt
import inspect
import sys
from abc import abstractmethod
# Aliases for builtins shadowed by classes to avoid annotations resolving to class members by ty
from builtins import bool as py_bool, str as py_str, type as py_type
from decimal import Decimal
from fractions import Fraction
from types import EllipsisType, ModuleType, MappingProxyType, GenericAlias
from uuid import UUID
from numpy.__config__ import show as show_config
from numpy._pytesttester import PytestTester
from numpy._core._internal import _ctypes
from numpy._typing import ( # type: ignore[deprecated]
# Arrays
ArrayLike,
NDArray,
_NestedSequence,
_ArrayLike,
_ArrayLikeBool_co,
_ArrayLikeUInt_co,
_ArrayLikeInt,
_ArrayLikeInt_co,
_ArrayLikeFloat64_co,
_ArrayLikeFloat_co,
_ArrayLikeComplex128_co,
_ArrayLikeComplex_co,
_ArrayLikeNumber_co,
_ArrayLikeObject_co,
_ArrayLikeBytes_co,
_ArrayLikeStr_co,
_ArrayLikeString_co,
_ArrayLikeTD64_co,
_ArrayLikeDT64_co,
# DTypes
DTypeLike,
_DTypeLike,
_DTypeLikeVoid,
_VoidDTypeLike,
# Shapes
_AnyShape,
_Shape,
_ShapeLike,
# Scalars
_CharLike_co,
_IntLike_co,
_FloatLike_co,
_TD64Like_co,
_NumberLike_co,
_ScalarLike_co,
# `number` precision
NBitBase,
# NOTE: Do not remove the extended precision bit-types even if seemingly unused;
# they're used by the mypy plugin
_128Bit,
_96Bit,
_64Bit,
_32Bit,
_16Bit,
_8Bit,
_NBitByte,
_NBitShort,
_NBitIntC,
_NBitIntP,
_NBitLong,
_NBitLongLong,
_NBitHalf,
_NBitSingle,
_NBitDouble,
_NBitLongDouble,
# Character codes
_BoolCodes,
_UInt8Codes,
_UInt16Codes,
_UInt32Codes,
_UInt64Codes,
_Int8Codes,
_Int16Codes,
_Int32Codes,
_Int64Codes,
_Float16Codes,
_Float32Codes,
_Float64Codes,
_Complex64Codes,
_Complex128Codes,
_IntCCodes,
_IntPCodes,
_LongCodes,
_LongLongCodes,
_UIntCCodes,
_UIntPCodes,
_ULongCodes,
_ULongLongCodes,
_LongDoubleCodes,
_CLongDoubleCodes,
_TD64Codes,
_StrCodes,
_BytesCodes,
_VoidCodes,
_ObjectCodes,
_StringCodes,
_UnsignedIntegerCodes,
_SignedIntegerCodes,
_IntegerCodes,
_FloatingCodes,
_ComplexFloatingCodes,
_InexactCodes,
_CharacterCodes,
# Ufuncs
_UFunc_Nin1_Nout1,
_UFunc_Nin2_Nout1,
_UFunc_Nin1_Nout2,
_UFunc_Nin2_Nout2,
_GUFunc_Nin2_Nout1,
)
from numpy._typing._char_codes import (
_DT64Codes_any,
_DT64Codes_date,
_DT64Codes_datetime,
_DT64Codes_int,
_TD64Codes_any,
_TD64Codes_int,
_TD64Codes_timedelta,
)
# NOTE: Numpy's mypy plugin is used for removing the types unavailable to the specific platform
from numpy._typing._extended_precision import (
float96,
float128,
complex192,
complex256,
)
from numpy._array_api_info import __array_namespace_info__
from collections.abc import (
Buffer,
Callable,
Iterable,
Iterator,
Mapping,
Sequence,
)
from typing import (
Any,
ClassVar,
Final,
Generic,
Literal as L,
LiteralString,
Never,
NoReturn,
Protocol,
Self,
SupportsComplex,
SupportsFloat,
SupportsInt,
SupportsIndex,
TypedDict,
final,
overload,
override,
type_check_only,
)
# NOTE: `typing_extensions` and `_typeshed` are always available in `.pyi` stubs, even
# if not available at runtime. This is because the `typeshed` stubs for the standard
# library include `typing_extensions` stubs:
# https://github.com/python/typeshed/blob/main/stdlib/typing_extensions.pyi
from _typeshed import Incomplete, StrOrBytesPath, SupportsFlush, SupportsLenAndGetItem, SupportsWrite
from typing_extensions import CapsuleType, TypeVar, deprecated
from numpy import (
char,
core,
ctypeslib,
dtypes,
exceptions,
f2py,
fft,
lib,
linalg,
ma,
polynomial,
random,
rec,
strings,
testing,
typing,
)
# available through `__getattr__`, but not in `__all__` or `__dir__`
from numpy import (
__config__ as __config__,
matlib as matlib,
matrixlib as matrixlib,
version as version,
)
from numpy._core.records import (
record,
recarray,
)
from numpy._core.function_base import (
linspace,
logspace,
geomspace,
)
from numpy._core.fromnumeric import (
take,
reshape,
choose,
repeat,
put,
swapaxes,
transpose,
matrix_transpose,
partition,
argpartition,
sort,
argsort,
argmax,
argmin,
searchsorted,
resize,
squeeze,
diagonal,
trace,
ravel,
nonzero,
shape,
compress,
clip,
sum,
all,
any,
cumsum,
cumulative_sum,
ptp,
max,
min,
amax,
amin,
prod,
cumprod,
cumulative_prod,
ndim,
size,
around,
round,
mean,
std,
var,
)
from numpy._core._asarray import (
require,
)
from numpy._core._type_aliases import (
sctypeDict,
)
from numpy._core._ufunc_config import (
seterr,
geterr,
setbufsize,
getbufsize,
seterrcall,
geterrcall,
errstate,
)
from numpy._core.arrayprint import (
set_printoptions,
get_printoptions,
array2string,
format_float_scientific,
format_float_positional,
array_repr,
array_str,
printoptions,
)
from numpy._core.einsumfunc import (
einsum,
einsum_path,
)
from numpy._core.getlimits import (
finfo,
iinfo,
)
from numpy._core.memmap import memmap
from numpy._core.multiarray import (
array,
empty_like,
empty,
zeros,
concatenate,
inner,
where,
lexsort,
can_cast,
min_scalar_type,
result_type,
dot,
vdot,
bincount,
copyto,
putmask,
packbits,
unpackbits,
shares_memory,
may_share_memory,
asarray,
asanyarray,
ascontiguousarray,
asfortranarray,
arange,
busdaycalendar,
busday_count,
busday_offset,
datetime_as_string,
datetime_data,
frombuffer,
fromfile,
fromiter,
is_busday,
promote_types,
fromstring,
frompyfunc,
flatiter,
nditer,
nested_iters,
flagsobj,
)
from numpy._core.numeric import (
zeros_like,
ones,
ones_like,
full,
full_like,
count_nonzero,
isfortran,
argwhere,
flatnonzero,
correlate,
convolve,
outer,
tensordot,
roll,
rollaxis,
moveaxis,
cross,
indices,
fromfunction,
isscalar,
binary_repr,
base_repr,
identity,
allclose,
isclose,
array_equal,
array_equiv,
astype,
)
from numpy._core.numerictypes import (
isdtype,
issubdtype,
ScalarType,
typecodes,
)
from numpy._core.shape_base import (
atleast_1d,
atleast_2d,
atleast_3d,
block,
hstack,
stack,
vstack,
unstack,
)
from ._expired_attrs_2_0 import __expired_attributes__ as __expired_attributes__
from ._globals import _CopyMode as _CopyMode
from ._globals import _NoValue as _NoValue, _NoValueType
from numpy.lib import (
scimath as emath,
)
from numpy.lib._arraypad_impl import (
pad,
)
from numpy.lib._arraysetops_impl import (
ediff1d,
intersect1d,
isin,
setdiff1d,
setxor1d,
union1d,
unique,
unique_all,
unique_counts,
unique_inverse,
unique_values,
)
from numpy.lib._function_base_impl import (
select,
piecewise,
trim_zeros,
copy,
iterable,
percentile,
diff,
gradient,
angle,
unwrap,
sort_complex,
flip,
rot90,
extract,
place,
asarray_chkfinite,
average,
digitize,
cov,
corrcoef,
median,
sinc,
hamming,
hanning,
bartlett,
blackman,
kaiser,
trapezoid,
i0,
meshgrid,
delete,
insert,
append,
interp,
quantile,
vectorize,
)
from numpy.lib._histograms_impl import (
histogram_bin_edges,
histogram,
histogramdd,
)
from numpy.lib._index_tricks_impl import (
ndenumerate,
ndindex,
ravel_multi_index,
unravel_index,
mgrid,
ogrid,
r_,
c_,
s_,
index_exp,
ix_,
fill_diagonal,
diag_indices,
diag_indices_from,
)
from numpy.lib._nanfunctions_impl import (
nansum,
nanmax,
nanmin,
nanargmax,
nanargmin,
nanmean,
nanmedian,
nanpercentile,
nanvar,
nanstd,
nanprod,
nancumsum,
nancumprod,
nanquantile,
)
from numpy.lib._npyio_impl import (
savetxt,
loadtxt,
genfromtxt,
load,
save,
savez,
savez_compressed,
fromregex,
)
from numpy.lib._polynomial_impl import (
poly,
roots,
polyint,
polyder,
polyadd,
polysub,
polymul,
polydiv,
polyval,
poly1d,
polyfit,
)
from numpy.lib._shape_base_impl import (
column_stack,
dstack,
array_split,
split,
hsplit,
vsplit,
dsplit,
apply_over_axes,
expand_dims,
apply_along_axis,
kron,
tile,
take_along_axis,
put_along_axis,
)
from numpy.lib._stride_tricks_impl import (
broadcast_to,
broadcast_arrays,
broadcast_shapes,
)
from numpy.lib._twodim_base_impl import (
diag,
diagflat,
eye,
fliplr,
flipud,
tri,
triu,
tril,
vander,
histogram2d,
mask_indices,
tril_indices,
tril_indices_from,
triu_indices,
triu_indices_from,
)
from numpy.lib._type_check_impl import (
mintypecode,
real,
imag,
iscomplex,
isreal,
iscomplexobj,
isrealobj,
nan_to_num,
real_if_close,
typename,
common_type,
)
from numpy.lib._ufunclike_impl import (
fix,
isposinf,
isneginf,
)
from numpy.lib._utils_impl import (
get_include,
info,
show_runtime,
)
from numpy.matrixlib import (
asmatrix,
bmat,
matrix,
)
__all__ = [
# __numpy_submodules__
"char", "core", "ctypeslib", "dtypes", "exceptions", "f2py", "fft", "lib", "linalg",
"ma", "polynomial", "random", "rec", "strings", "test", "testing", "typing",
# _core.__all__
"abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "atan2", "bitwise_invert",
"bitwise_left_shift", "bitwise_right_shift", "concat", "pow", "permute_dims",
"memmap", "sctypeDict", "record", "recarray",
# _core.numeric.__all__
"newaxis", "ndarray", "flatiter", "nditer", "nested_iters", "ufunc", "arange",
"array", "asarray", "asanyarray", "ascontiguousarray", "asfortranarray", "zeros",
"count_nonzero", "empty", "broadcast", "dtype", "fromstring", "fromfile",
"frombuffer", "from_dlpack", "where", "argwhere", "copyto", "concatenate",
"lexsort", "astype", "can_cast", "promote_types", "min_scalar_type", "result_type",
"isfortran", "empty_like", "zeros_like", "ones_like", "correlate", "convolve",
"inner", "dot", "outer", "vdot", "roll", "rollaxis", "moveaxis", "cross",
"tensordot", "little_endian", "fromiter", "array_equal", "array_equiv", "indices",
"fromfunction", "isclose", "isscalar", "binary_repr", "base_repr", "ones",
"identity", "allclose", "putmask", "flatnonzero", "inf", "nan", "False_", "True_",
"bitwise_not", "full", "full_like", "matmul", "vecdot", "vecmat",
"shares_memory", "may_share_memory",
"all", "amax", "amin", "any", "argmax", "argmin", "argpartition", "argsort",
"around", "choose", "clip", "compress", "cumprod", "cumsum", "cumulative_prod",
"cumulative_sum", "diagonal", "mean", "max", "min", "matrix_transpose", "ndim",
"nonzero", "partition", "prod", "ptp", "put", "ravel", "repeat", "reshape",
"resize", "round", "searchsorted", "shape", "size", "sort", "squeeze", "std", "sum",
"swapaxes", "take", "trace", "transpose", "var",
"absolute", "add", "arccos", "arccosh", "arcsin", "arcsinh", "arctan", "arctan2",
"arctanh", "bitwise_and", "bitwise_or", "bitwise_xor", "cbrt", "ceil", "conj",
"conjugate", "copysign", "cos", "cosh", "bitwise_count", "deg2rad", "degrees",
"divide", "divmod", "e", "equal", "euler_gamma", "exp", "exp2", "expm1", "fabs",
"floor", "floor_divide", "float_power", "fmax", "fmin", "fmod", "frexp",
"frompyfunc", "gcd", "greater", "greater_equal", "heaviside", "hypot", "invert",
"isfinite", "isinf", "isnan", "isnat", "lcm", "ldexp", "left_shift", "less",
"less_equal", "log", "log10", "log1p", "log2", "logaddexp", "logaddexp2",
"logical_and", "logical_not", "logical_or", "logical_xor", "matvec", "maximum", "minimum",
"mod", "modf", "multiply", "negative", "nextafter", "not_equal", "pi", "positive",
"power", "rad2deg", "radians", "reciprocal", "remainder", "right_shift", "rint",
"sign", "signbit", "sin", "sinh", "spacing", "sqrt", "square", "subtract", "tan",
"tanh", "true_divide", "trunc", "ScalarType", "typecodes", "issubdtype",
"datetime_data", "datetime_as_string", "busday_offset", "busday_count", "is_busday",
"busdaycalendar", "isdtype",
"complexfloating", "character", "unsignedinteger", "inexact", "generic", "floating",
"integer", "signedinteger", "number", "flexible", "bool", "float16", "float32",
"float64", "longdouble", "complex64", "complex128", "clongdouble",
"bytes_", "str_", "void", "object_", "datetime64", "timedelta64", "int8", "byte",
"uint8", "ubyte", "int16", "short", "uint16", "ushort", "int32", "intc", "uint32",
"uintc", "int64", "long", "uint64", "ulong", "longlong", "ulonglong", "intp",
"uintp", "double", "cdouble", "single", "csingle", "half", "bool_", "int_", "uint",
"float96", "float128", "complex192", "complex256",
"array2string", "array_str", "array_repr", "set_printoptions", "get_printoptions",
"printoptions", "format_float_positional", "format_float_scientific", "require",
"seterr", "geterr", "setbufsize", "getbufsize", "seterrcall", "geterrcall",
"errstate",
# _core.function_base.__all__
"logspace", "linspace", "geomspace",
# _core.getlimits.__all__
"finfo", "iinfo",
# _core.shape_base.__all__
"atleast_1d", "atleast_2d", "atleast_3d", "block", "hstack", "stack", "unstack",
"vstack",
# _core.einsumfunc.__all__
"einsum", "einsum_path",
# matrixlib.__all__
"matrix", "bmat", "asmatrix",
# lib._histograms_impl.__all__
"histogram", "histogramdd", "histogram_bin_edges",
# lib._nanfunctions_impl.__all__
"nansum", "nanmax", "nanmin", "nanargmax", "nanargmin", "nanmean", "nanmedian",
"nanpercentile", "nanvar", "nanstd", "nanprod", "nancumsum", "nancumprod",
"nanquantile",
# lib._function_base_impl.__all__
"select", "piecewise", "trim_zeros", "copy", "iterable", "percentile", "diff",
"gradient", "angle", "unwrap", "sort_complex", "flip", "rot90", "extract", "place",
"vectorize", "asarray_chkfinite", "average", "bincount", "digitize", "cov",
"corrcoef", "median", "sinc", "hamming", "hanning", "bartlett", "blackman",
"kaiser", "trapezoid", "i0", "meshgrid", "delete", "insert", "append",
"interp", "quantile",
# lib._twodim_base_impl.__all__
"diag", "diagflat", "eye", "fliplr", "flipud", "tri", "triu", "tril", "vander",
"histogram2d", "mask_indices", "tril_indices", "tril_indices_from", "triu_indices",
"triu_indices_from",
# lib._shape_base_impl.__all__
"column_stack", "dstack", "array_split", "split", "hsplit", "vsplit", "dsplit",
"apply_over_axes", "expand_dims", "apply_along_axis", "kron", "tile",
"take_along_axis", "put_along_axis",
# lib._type_check_impl.__all__
"iscomplexobj", "isrealobj", "imag", "iscomplex", "isreal", "nan_to_num", "real",
"real_if_close", "typename", "mintypecode", "common_type",
# lib._arraysetops_impl.__all__
"ediff1d", "intersect1d", "isin", "setdiff1d", "setxor1d", "union1d",
"unique", "unique_all", "unique_counts", "unique_inverse", "unique_values",
# lib._ufunclike_impl.__all__
"fix", "isneginf", "isposinf",
# lib._arraypad_impl.__all__
"pad",
# lib._utils_impl.__all__
"get_include", "info", "show_runtime",
# lib._stride_tricks_impl.__all__
"broadcast_to", "broadcast_arrays", "broadcast_shapes",
# lib._polynomial_impl.__all__
"poly", "roots", "polyint", "polyder", "polyadd", "polysub", "polymul", "polydiv",
"polyval", "poly1d", "polyfit",
# lib._npyio_impl.__all__
"savetxt", "loadtxt", "genfromtxt", "load", "save", "savez", "savez_compressed",
"packbits", "unpackbits", "fromregex",
# lib._index_tricks_impl.__all__
"ravel_multi_index", "unravel_index", "mgrid", "ogrid", "r_", "c_", "s_",
"index_exp", "ix_", "ndenumerate", "ndindex", "fill_diagonal", "diag_indices",
"diag_indices_from",
# __init__.__all__
"emath", "show_config", "__version__", "__array_namespace_info__",
] # fmt: skip
### Type parameters (with defaults); for internal use only
_ArrayT_co = TypeVar("_ArrayT_co", bound=ndarray, default=ndarray, covariant=True)
_ShapeT_co = TypeVar("_ShapeT_co", bound=_Shape, default=_AnyShape, covariant=True)
_DTypeT_co = TypeVar("_DTypeT_co", bound=dtype, default=dtype, covariant=True)
_ScalarT_co = TypeVar("_ScalarT_co", bound=generic, default=Any, covariant=True)
# intentionally invariant
_NBitT = TypeVar("_NBitT", bound=NBitBase, default=Any) # pyright: ignore[reportDeprecated]
_NBitT1 = TypeVar("_NBitT1", bound=NBitBase, default=Any) # pyright: ignore[reportDeprecated]
_NBitT2 = TypeVar("_NBitT2", bound=NBitBase, default=_NBitT1) # pyright: ignore[reportDeprecated]
_ItemT_co = TypeVar("_ItemT_co", default=Any, covariant=True)
_BoolItemT_co = TypeVar("_BoolItemT_co", bound=py_bool, default=py_bool, covariant=True)
_NumberItemT_co = TypeVar("_NumberItemT_co", bound=complex, default=Any, covariant=True) # either int, float, or complex
_InexactItemT_co = TypeVar("_InexactItemT_co", bound=complex, default=Any, covariant=True) # either float or complex
_FlexibleItemT_co = TypeVar("_FlexibleItemT_co", bound=bytes | str | tuple[Any, ...], default=Any, covariant=True)
_CharacterItemT_co = TypeVar("_CharacterItemT_co", bound=bytes | str, default=Any, covariant=True)
_TD64ItemT_co = TypeVar("_TD64ItemT_co", bound=_TD64Item, default=Any, covariant=True)
_DT64ItemT_co = TypeVar("_DT64ItemT_co", bound=_DT64Item, default=Any, covariant=True)
### Type Aliases (for internal use only)
type _Falsy = L[False, 0] | bool_[L[False]]
type _Truthy = L[True, 1] | bool_[L[True]]
type _1D = tuple[int]
type _2D = tuple[int, int]
type _3D = tuple[int, int, int]
type _2Tuple[T] = tuple[T, T]
type _3Tuple[T] = tuple[T, T, T]
type _ArrayUInt_co = NDArray[unsignedinteger | bool_]
type _ArrayInt_co = NDArray[integer | bool_]
type _ArrayFloat64_co = NDArray[floating[_64Bit] | float32 | float16 | integer | bool_]
type _ArrayFloat_co = NDArray[floating | integer | bool_]
type _ArrayComplex128_co = NDArray[number[_64Bit] | number[_32Bit] | float16 | integer | bool_]
type _ArrayComplex_co = NDArray[inexact | integer | bool_]
type _ArrayNumber_co = NDArray[number | bool_]
type _ArrayTD64_co = NDArray[timedelta64 | integer | bool_]
type _ArrayString = ndarray[_AnyShape, dtype[str_] | dtypes.StringDType]
type _ArrayNumeric = NDArray[number | timedelta64 | object_]
type _ScalarNotObject = bool_ | number | flexible | datetime64 | timedelta64
type _Float64_co = float | floating[_64Bit] | float32 | float16 | integer | bool_
type _Complex64_co = number[_32Bit] | number[_16Bit] | number[_8Bit] | py_bool | bool_
type _Complex128_co = complex | number[_64Bit] | _Complex64_co
type _ToIndex = SupportsIndex | slice | EllipsisType | _ArrayLikeInt_co | None
type _ToIndices = _ToIndex | tuple[_ToIndex, ...]
type _UnsignedIntegerCType = type[
ct.c_uint8 | ct.c_uint16 | ct.c_uint32 | ct.c_uint64
| ct.c_ushort | ct.c_uint | ct.c_ulong | ct.c_ulonglong
| ct.c_size_t | ct.c_void_p
] # fmt: skip
type _SignedIntegerCType = type[
ct.c_int8 | ct.c_int16 | ct.c_int32 | ct.c_int64
| ct.c_short | ct.c_int | ct.c_long | ct.c_longlong
| ct.c_ssize_t
] # fmt: skip
type _FloatingCType = type[ct.c_float | ct.c_double | ct.c_longdouble]
type _IntegerCType = _UnsignedIntegerCType | _SignedIntegerCType
# some commonly used builtin types that are known to result in a
# `dtype[object_]`, when their *type* is passed to the `dtype` constructor
# NOTE: `builtins.object` should not be included here
type _BuiltinObjectLike = (
slice | Decimal | Fraction | UUID
| dt.date | dt.time | dt.timedelta | dt.tzinfo
| tuple[Any, ...] | list[Any] | set[Any] | frozenset[Any] | dict[Any, Any]
) # fmt: skip
# Introduce an alias for `dtype` to avoid naming conflicts.
# NOTE: This should _not_ be `Final[_]`, `_: TypeAlias`, or `type _`
_dtype = dtype
type _ByteOrderChar = L["<", ">", "=", "|"]
# can be anything, is case-insensitive, and only the first character matters
type _ByteOrder = L[
"S", # swap the current order (default)
"<", "L", "little", # little-endian
">", "B", "big", # big endian
"=", "N", "native", # native order
"|", "I", # ignore
] # fmt: skip
type _DTypeKind = L[
"b", # boolean
"i", # signed integer
"u", # unsigned integer
"f", # floating-point
"c", # complex floating-point
"m", # timedelta64
"M", # datetime64
"O", # python object
"S", # byte-string (fixed-width)
"U", # unicode-string (fixed-width)
"V", # void
"T", # unicode-string (variable-width)
]
type _DTypeChar = L[
"?", # bool
"b", # byte
"B", # ubyte
"h", # short
"H", # ushort
"i", # intc
"I", # uintc
"l", # long
"L", # ulong
"q", # longlong
"Q", # ulonglong
"e", # half
"f", # single
"d", # double
"g", # longdouble
"F", # csingle
"D", # cdouble
"G", # clongdouble
"O", # object
"S", # bytes_ (S0)
"U", # str_
"V", # void
"M", # datetime64
"m", # timedelta64
"c", # bytes_ (S1)
"T", # StringDType
]
type _DTypeNum = L[
0, # bool
1, # byte
2, # ubyte
3, # short
4, # ushort
5, # intc
6, # uintc
7, # long
8, # ulong
9, # longlong
10, # ulonglong
23, # half
11, # single
12, # double
13, # longdouble
14, # csingle
15, # cdouble
16, # clongdouble
17, # object
18, # bytes_
19, # str_
20, # void
21, # datetime64
22, # timedelta64
25, # no type
256, # user-defined
2056, # StringDType
]
type _DTypeBuiltinKind = L[0, 1, 2]
type _ArrayAPIVersion = L["2021.12", "2022.12", "2023.12", "2024.12", "2025.12"]
type _CastingKind = L["no", "equiv", "safe", "same_kind", "same_value", "unsafe"]
type _OrderKACF = L["K", "A", "C", "F"] | None
type _OrderACF = L["A", "C", "F"] | None
type _OrderCF = L["C", "F"] | None
type _ModeKind = L["raise", "wrap", "clip"]
type _PartitionKind = L["introselect"]
# in practice, only the first case-insensitive character is considered (so e.g.
# "QuantumSort3000" will be interpreted as quicksort).
type _SortKind = L[
"Q", "quick", "quicksort",
"M", "merge", "mergesort",
"H", "heap", "heapsort",
"S", "stable", "stablesort",
] # fmt: skip
type _SortSide = L["left", "right"]
type _ConvertibleToInt = SupportsInt | SupportsIndex | _CharLike_co
type _ConvertibleToFloat = SupportsFloat | SupportsIndex | _CharLike_co
type _ConvertibleToComplex = SupportsComplex | SupportsFloat | SupportsIndex | _CharLike_co
type _ConvertibleToTD64 = dt.timedelta | int | _CharLike_co | character | number | timedelta64 | bool_ | None
type _ConvertibleToDT64 = dt.date | int | _CharLike_co | character | number | datetime64 | bool_ | None
type _NDIterFlagsKind = L[
"buffered",
"c_index",
"copy_if_overlap",
"common_dtype",
"delay_bufalloc",
"external_loop",
"f_index",
"grow_inner", "growinner",
"multi_index",
"ranged",
"refs_ok",
"reduce_ok",
"zerosize_ok",
]
type _NDIterFlagsOp = L[
"aligned",
"allocate",
"arraymask",
"copy",
"config",
"nbo",
"no_subtype",
"no_broadcast",
"overlap_assume_elementwise",
"readonly",
"readwrite",
"updateifcopy",
"virtual",
"writeonly",
"writemasked",
]
type _DT64Item = dt.date | int | None
type _TD64Item = dt.timedelta | int | None
type _DT64Date = _HasDateAttributes | L["TODAY", "today", b"TODAY", b"today"]
type _DT64Now = L["NOW", "now", b"NOW", b"now"]
type _NaTValue = L["NAT", "NaT", "nat", b"NAT", b"NaT", b"nat"]
type _MonthUnit = L["Y", "M", b"Y", b"M"]
type _DayUnit = L["W", "D", b"W", b"D"]
type _DateUnit = L[_MonthUnit, _DayUnit]
type _NativeTimeUnit = L["h", "m", "s", "ms", "us", "μs", b"h", b"m", b"s", b"ms", b"us"]
type _IntTimeUnit = L["ns", "ps", "fs", "as", b"ns", b"ps", b"fs", b"as"]
type _TimeUnit = L[_NativeTimeUnit, _IntTimeUnit]
type _NativeTD64Unit = L[_DayUnit, _NativeTimeUnit]
type _IntTD64Unit = L[_MonthUnit, _IntTimeUnit]
type _TD64Unit = L[_DateUnit, _TimeUnit]
type _TimeUnitSpec[UnitT: _TD64Unit] = _TD64Unit | tuple[_TD64Unit, SupportsIndex]
### TypedDict's (for internal use only)
@type_check_only
class _FormerAttrsDict(TypedDict):
object: LiteralString
float: LiteralString
complex: LiteralString
str: LiteralString
int: LiteralString
### Protocols (for internal use only)
@final
@type_check_only
class _SupportsLT(Protocol):
def __lt__(self, other: Any, /) -> Any: ...
@final
@type_check_only
class _SupportsLE(Protocol):
def __le__(self, other: Any, /) -> Any: ...
@final
@type_check_only
class _SupportsGT(Protocol):
def __gt__(self, other: Any, /) -> Any: ...
@final
@type_check_only
class _SupportsGE(Protocol):
def __ge__(self, other: Any, /) -> Any: ...
@type_check_only
class _SupportsFileMethods(SupportsFlush, Protocol):
# Protocol for representing file-like-objects accepted by `ndarray.tofile` and `fromfile`
def fileno(self) -> SupportsIndex: ...
def tell(self) -> SupportsIndex: ...
def seek(self, offset: int, whence: int, /) -> object: ...
@type_check_only
class _SupportsDLPack[StreamT](Protocol):
def __dlpack__(self, /, *, stream: StreamT | None = None) -> CapsuleType: ...
@type_check_only
class _HasDType[DTypeT](Protocol): # DTypeT bound was intentionally left out
@property
def dtype(self, /) -> DTypeT: ...