Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
__init__.pyi6203 linesDownload Raw Back to numpy
1# ruff: noqa: I001
2import builtins
3import sys
4import mmap
5import ctypes as ct
6import array as _array
7import datetime as dt
8import inspect
9from abc import abstractmethod
10from types import EllipsisType, ModuleType, TracebackType, MappingProxyType, GenericAlias
11from decimal import Decimal
12from fractions import Fraction
13from uuid import UUID
14
15import numpy as np
16from numpy.__config__ import show as show_config
17from numpy._pytesttester import PytestTester
18from numpy._core._internal import _ctypes
19
20from numpy._typing import (  # type: ignore[deprecated]
21    # Arrays
22    ArrayLike,
23    NDArray,
24    _SupportsArray,
25    _NestedSequence,
26    _ArrayLike,
27    _ArrayLikeBool_co,
28    _ArrayLikeUInt_co,
29    _ArrayLikeInt,
30    _ArrayLikeInt_co,
31    _ArrayLikeFloat64_co,
32    _ArrayLikeFloat_co,
33    _ArrayLikeComplex128_co,
34    _ArrayLikeComplex_co,
35    _ArrayLikeNumber_co,
36    _ArrayLikeObject_co,
37    _ArrayLikeBytes_co,
38    _ArrayLikeStr_co,
39    _ArrayLikeString_co,
40    _ArrayLikeTD64_co,
41    _ArrayLikeDT64_co,
42    # DTypes
43    DTypeLike,
44    _DTypeLike,
45    _DTypeLikeVoid,
46    _VoidDTypeLike,
47    # Shapes
48    _AnyShape,
49    _Shape,
50    _ShapeLike,
51    # Scalars
52    _CharLike_co,
53    _IntLike_co,
54    _FloatLike_co,
55    _TD64Like_co,
56    _NumberLike_co,
57    _ScalarLike_co,
58    # `number` precision
59    NBitBase,
60    # NOTE: Do not remove the extended precision bit-types even if seemingly unused;
61    # they're used by the mypy plugin
62    _128Bit,
63    _96Bit,
64    _64Bit,
65    _32Bit,
66    _16Bit,
67    _8Bit,
68    _NBitByte,
69    _NBitShort,
70    _NBitIntC,
71    _NBitIntP,
72    _NBitLong,
73    _NBitLongLong,
74    _NBitHalf,
75    _NBitSingle,
76    _NBitDouble,
77    _NBitLongDouble,
78    # Character codes
79    _BoolCodes,
80    _UInt8Codes,
81    _UInt16Codes,
82    _UInt32Codes,
83    _UInt64Codes,
84    _Int8Codes,
85    _Int16Codes,
86    _Int32Codes,
87    _Int64Codes,
88    _Float16Codes,
89    _Float32Codes,
90    _Float64Codes,
91    _Complex64Codes,
92    _Complex128Codes,
93    _ByteCodes,
94    _ShortCodes,
95    _IntCCodes,
96    _IntPCodes,
97    _LongCodes,
98    _LongLongCodes,
99    _UByteCodes,
100    _UShortCodes,
101    _UIntCCodes,
102    _UIntPCodes,
103    _ULongCodes,
104    _ULongLongCodes,
105    _HalfCodes,
106    _SingleCodes,
107    _DoubleCodes,
108    _LongDoubleCodes,
109    _CSingleCodes,
110    _CDoubleCodes,
111    _CLongDoubleCodes,
112    _DT64Codes,
113    _TD64Codes,
114    _StrCodes,
115    _BytesCodes,
116    _VoidCodes,
117    _ObjectCodes,
118    _StringCodes,
119    _UnsignedIntegerCodes,
120    _SignedIntegerCodes,
121    _IntegerCodes,
122    _FloatingCodes,
123    _ComplexFloatingCodes,
124    _InexactCodes,
125    _CharacterCodes,
126    # Ufuncs
127    _UFunc_Nin1_Nout1,
128    _UFunc_Nin2_Nout1,
129    _UFunc_Nin1_Nout2,
130    _UFunc_Nin2_Nout2,
131    _GUFunc_Nin2_Nout1,
132)
133
134# NOTE: Numpy's mypy plugin is used for removing the types unavailable to the specific platform
135from numpy._typing._extended_precision import (
136    float96,
137    float128,
138    complex192,
139    complex256,
140)
141
142from numpy._array_api_info import __array_namespace_info__
143
144from collections.abc import (
145    Callable,
146    Iterable,
147    Iterator,
148    Mapping,
149    Sequence,
150)
151
152if sys.version_info >= (3, 12):
153    from collections.abc import Buffer as _SupportsBuffer
154else:
155    _SupportsBuffer: TypeAlias = (
156        bytes
157        | bytearray
158        | memoryview
159        | _array.array[Any]
160        | mmap.mmap
161        | NDArray[Any]
162        | generic
163    )
164
165from typing import (
166    Any,
167    ClassVar,
168    Final,
169    Generic,
170    Literal as L,
171    LiteralString,
172    Never,
173    NoReturn,
174    Protocol,
175    Self,
176    SupportsComplex,
177    SupportsFloat,
178    SupportsInt,
179    SupportsIndex,
180    TypeAlias,
181    TypedDict,
182    final,
183    overload,
184    type_check_only,
185)
186
187# NOTE: `typing_extensions` and `_typeshed` are always available in `.pyi` stubs, even
188# if not available at runtime. This is because the `typeshed` stubs for the standard
189# library include `typing_extensions` stubs:
190# https://github.com/python/typeshed/blob/main/stdlib/typing_extensions.pyi
191from _typeshed import Incomplete, StrOrBytesPath, SupportsFlush, SupportsLenAndGetItem, SupportsWrite
192from typing_extensions import CapsuleType, TypeVar, deprecated, override
193
194from numpy import (
195    char,
196    core,
197    ctypeslib,
198    dtypes,
199    exceptions,
200    f2py,
201    fft,
202    lib,
203    linalg,
204    ma,
205    polynomial,
206    random,
207    rec,
208    strings,
209    testing,
210    typing,
211)
212
213# available through `__getattr__`, but not in `__all__` or `__dir__`
214from numpy import (
215    __config__ as __config__,
216    matlib as matlib,
217    matrixlib as matrixlib,
218    version as version,
219)
220if sys.version_info < (3, 12):
221    from numpy import distutils as distutils
222
223from numpy._core.records import (
224    record,
225    recarray,
226)
227
228from numpy._core.function_base import (
229    linspace,
230    logspace,
231    geomspace,
232)
233
234from numpy._core.fromnumeric import (
235    take,
236    reshape,
237    choose,
238    repeat,
239    put,
240    swapaxes,
241    transpose,
242    matrix_transpose,
243    partition,
244    argpartition,
245    sort,
246    argsort,
247    argmax,
248    argmin,
249    searchsorted,
250    resize,
251    squeeze,
252    diagonal,
253    trace,
254    ravel,
255    nonzero,
256    shape,
257    compress,
258    clip,
259    sum,
260    all,
261    any,
262    cumsum,
263    cumulative_sum,
264    ptp,
265    max,
266    min,
267    amax,
268    amin,
269    prod,
270    cumprod,
271    cumulative_prod,
272    ndim,
273    size,
274    around,
275    round,
276    mean,
277    std,
278    var,
279)
280
281from numpy._core._asarray import (
282    require,
283)
284
285from numpy._core._type_aliases import (
286    sctypeDict,
287)
288
289from numpy._core._ufunc_config import (
290    seterr,
291    geterr,
292    setbufsize,
293    getbufsize,
294    seterrcall,
295    geterrcall,
296    errstate,
297)
298
299from numpy._core.arrayprint import (
300    set_printoptions,
301    get_printoptions,
302    array2string,
303    format_float_scientific,
304    format_float_positional,
305    array_repr,
306    array_str,
307    printoptions,
308)
309
310from numpy._core.einsumfunc import (
311    einsum,
312    einsum_path,
313)
314from numpy._core.getlimits import (
315    finfo,
316    iinfo,
317)
318
319from numpy._core.multiarray import (
320    array,
321    empty_like,
322    empty,
323    zeros,
324    concatenate,
325    inner,
326    where,
327    lexsort,
328    can_cast,
329    min_scalar_type,
330    result_type,
331    dot,
332    vdot,
333    bincount,
334    copyto,
335    putmask,
336    packbits,
337    unpackbits,
338    shares_memory,
339    may_share_memory,
340    asarray,
341    asanyarray,
342    ascontiguousarray,
343    asfortranarray,
344    arange,
345    busday_count,
346    busday_offset,
347    datetime_as_string,
348    datetime_data,
349    frombuffer,
350    fromfile,
351    fromiter,
352    is_busday,
353    promote_types,
354    fromstring,
355    frompyfunc,
356    nested_iters,
357    flagsobj,
358)
359
360from numpy._core.numeric import (
361    zeros_like,
362    ones,
363    ones_like,
364    full,
365    full_like,
366    count_nonzero,
367    isfortran,
368    argwhere,
369    flatnonzero,
370    correlate,
371    convolve,
372    outer,
373    tensordot,
374    roll,
375    rollaxis,
376    moveaxis,
377    cross,
378    indices,
379    fromfunction,
380    isscalar,
381    binary_repr,
382    base_repr,
383    identity,
384    allclose,
385    isclose,
386    array_equal,
387    array_equiv,
388    astype,
389)
390
391from numpy._core.numerictypes import (
392    isdtype,
393    issubdtype,
394    ScalarType,
395    typecodes,
396)
397
398from numpy._core.shape_base import (
399    atleast_1d,
400    atleast_2d,
401    atleast_3d,
402    block,
403    hstack,
404    stack,
405    vstack,
406    unstack,
407)
408
409from ._expired_attrs_2_0 import __expired_attributes__ as __expired_attributes__
410from ._globals import _CopyMode as _CopyMode
411from ._globals import _NoValue as _NoValue, _NoValueType
412
413from numpy.lib import (
414    scimath as emath,
415)
416
417from numpy.lib._arraypad_impl import (
418    pad,
419)
420
421from numpy.lib._arraysetops_impl import (
422    ediff1d,
423    intersect1d,
424    isin,
425    setdiff1d,
426    setxor1d,
427    union1d,
428    unique,
429    unique_all,
430    unique_counts,
431    unique_inverse,
432    unique_values,
433)
434
435from numpy.lib._function_base_impl import (  # type: ignore[deprecated]
436    select,
437    piecewise,
438    trim_zeros,
439    copy,
440    iterable,
441    percentile,
442    diff,
443    gradient,
444    angle,
445    unwrap,
446    sort_complex,
447    flip,
448    rot90,
449    extract,
450    place,
451    asarray_chkfinite,
452    average,
453    digitize,
454    cov,
455    corrcoef,
456    median,
457    sinc,
458    hamming,
459    hanning,
460    bartlett,
461    blackman,
462    kaiser,
463    trapezoid,
464    i0,
465    meshgrid,
466    delete,
467    insert,
468    append,
469    interp,
470    quantile,
471    vectorize,
472)
473
474from numpy.lib._histograms_impl import (
475    histogram_bin_edges,
476    histogram,
477    histogramdd,
478)
479
480from numpy.lib._index_tricks_impl import (
481    ndenumerate,
482    ndindex,
483    ravel_multi_index,
484    unravel_index,
485    mgrid,
486    ogrid,
487    r_,
488    c_,
489    s_,
490    index_exp,
491    ix_,
492    fill_diagonal,
493    diag_indices,
494    diag_indices_from,
495)
496
497from numpy.lib._nanfunctions_impl import (
498    nansum,
499    nanmax,
500    nanmin,
501    nanargmax,
502    nanargmin,
503    nanmean,
504    nanmedian,
505    nanpercentile,
506    nanvar,
507    nanstd,
508    nanprod,
509    nancumsum,
510    nancumprod,
511    nanquantile,
512)
513
514from numpy.lib._npyio_impl import (
515    savetxt,
516    loadtxt,
517    genfromtxt,
518    load,
519    save,
520    savez,
521    savez_compressed,
522    fromregex,
523)
524
525from numpy.lib._polynomial_impl import (
526    poly,
527    roots,
528    polyint,
529    polyder,
530    polyadd,
531    polysub,
532    polymul,
533    polydiv,
534    polyval,
535    polyfit,
536)
537
538from numpy.lib._shape_base_impl import (  # type: ignore[deprecated]
539    column_stack,
540    row_stack,
541    dstack,
542    array_split,
543    split,
544    hsplit,
545    vsplit,
546    dsplit,
547    apply_over_axes,
548    expand_dims,
549    apply_along_axis,
550    kron,
551    tile,
552    take_along_axis,
553    put_along_axis,
554)
555
556from numpy.lib._stride_tricks_impl import (
557    broadcast_to,
558    broadcast_arrays,
559    broadcast_shapes,
560)
561
562from numpy.lib._twodim_base_impl import (
563    diag,
564    diagflat,
565    eye,
566    fliplr,
567    flipud,
568    tri,
569    triu,
570    tril,
571    vander,
572    histogram2d,
573    mask_indices,
574    tril_indices,
575    tril_indices_from,
576    triu_indices,
577    triu_indices_from,
578)
579
580from numpy.lib._type_check_impl import (
581    mintypecode,
582    real,
583    imag,
584    iscomplex,
585    isreal,
586    iscomplexobj,
587    isrealobj,
588    nan_to_num,
589    real_if_close,
590    typename,
591    common_type,
592)
593
594from numpy.lib._ufunclike_impl import (
595    fix,
596    isposinf,
597    isneginf,
598)
599
600from numpy.lib._utils_impl import (
601    get_include,
602    info,
603    show_runtime,
604)
605
606from numpy.matrixlib import (
607    asmatrix,
608    bmat,
609    matrix,
610)
611
612__all__ = [  # noqa: RUF022
613    # __numpy_submodules__
614    "char", "core", "ctypeslib", "dtypes", "exceptions", "f2py", "fft", "lib", "linalg",
615    "ma", "polynomial", "random", "rec", "strings", "test", "testing", "typing",
616
617    # _core.__all__
618    "abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "atan2", "bitwise_invert",
619    "bitwise_left_shift", "bitwise_right_shift", "concat", "pow", "permute_dims",
620    "memmap", "sctypeDict", "record", "recarray",
621
622    # _core.numeric.__all__
623    "newaxis", "ndarray", "flatiter", "nditer", "nested_iters", "ufunc", "arange",
624    "array", "asarray", "asanyarray", "ascontiguousarray", "asfortranarray", "zeros",
625    "count_nonzero", "empty", "broadcast", "dtype", "fromstring", "fromfile",
626    "frombuffer", "from_dlpack", "where", "argwhere", "copyto", "concatenate",
627    "lexsort", "astype", "can_cast", "promote_types", "min_scalar_type", "result_type",
628    "isfortran", "empty_like", "zeros_like", "ones_like", "correlate", "convolve",
629    "inner", "dot", "outer", "vdot", "roll", "rollaxis", "moveaxis", "cross",
630    "tensordot", "little_endian", "fromiter", "array_equal", "array_equiv", "indices",
631    "fromfunction", "isclose", "isscalar", "binary_repr", "base_repr", "ones",
632    "identity", "allclose", "putmask", "flatnonzero", "inf", "nan", "False_", "True_",
633    "bitwise_not", "full", "full_like", "matmul", "vecdot", "vecmat",
634    "shares_memory", "may_share_memory",
635    "all", "amax", "amin", "any", "argmax", "argmin", "argpartition", "argsort",
636    "around", "choose", "clip", "compress", "cumprod", "cumsum", "cumulative_prod",
637    "cumulative_sum", "diagonal", "mean", "max", "min", "matrix_transpose", "ndim",
638    "nonzero", "partition", "prod", "ptp", "put", "ravel", "repeat", "reshape",
639    "resize", "round", "searchsorted", "shape", "size", "sort", "squeeze", "std", "sum",
640    "swapaxes", "take", "trace", "transpose", "var",
641    "absolute", "add", "arccos", "arccosh", "arcsin", "arcsinh", "arctan", "arctan2",
642    "arctanh", "bitwise_and", "bitwise_or", "bitwise_xor", "cbrt", "ceil", "conj",
643    "conjugate", "copysign", "cos", "cosh", "bitwise_count", "deg2rad", "degrees",
644    "divide", "divmod", "e", "equal", "euler_gamma", "exp", "exp2", "expm1", "fabs",
645    "floor", "floor_divide", "float_power", "fmax", "fmin", "fmod", "frexp",
646    "frompyfunc", "gcd", "greater", "greater_equal", "heaviside", "hypot", "invert",
647    "isfinite", "isinf", "isnan", "isnat", "lcm", "ldexp", "left_shift", "less",
648    "less_equal", "log", "log10", "log1p", "log2", "logaddexp", "logaddexp2",
649    "logical_and", "logical_not", "logical_or", "logical_xor", "matvec", "maximum", "minimum",
650    "mod", "modf", "multiply", "negative", "nextafter", "not_equal", "pi", "positive",
651    "power", "rad2deg", "radians", "reciprocal", "remainder", "right_shift", "rint",
652    "sign", "signbit", "sin", "sinh", "spacing", "sqrt", "square", "subtract", "tan",
653    "tanh", "true_divide", "trunc", "ScalarType", "typecodes", "issubdtype",
654    "datetime_data", "datetime_as_string", "busday_offset", "busday_count", "is_busday",
655    "busdaycalendar", "isdtype",
656    "complexfloating", "character", "unsignedinteger", "inexact", "generic", "floating",
657    "integer", "signedinteger", "number", "flexible", "bool", "float16", "float32",
658    "float64", "longdouble", "complex64", "complex128", "clongdouble",
659    "bytes_", "str_", "void", "object_", "datetime64", "timedelta64", "int8", "byte",
660    "uint8", "ubyte", "int16", "short", "uint16", "ushort", "int32", "intc", "uint32",
661    "uintc", "int64", "long", "uint64", "ulong", "longlong", "ulonglong", "intp",
662    "uintp", "double", "cdouble", "single", "csingle", "half", "bool_", "int_", "uint",
663    "float96", "float128", "complex192", "complex256",
664    "array2string", "array_str", "array_repr", "set_printoptions", "get_printoptions",
665    "printoptions", "format_float_positional", "format_float_scientific", "require",
666    "seterr", "geterr", "setbufsize", "getbufsize", "seterrcall", "geterrcall",
667    "errstate",
668    # _core.function_base.__all__
669    "logspace", "linspace", "geomspace",
670    # _core.getlimits.__all__
671    "finfo", "iinfo",
672    # _core.shape_base.__all__
673    "atleast_1d", "atleast_2d", "atleast_3d", "block", "hstack", "stack", "unstack",
674    "vstack",
675    # _core.einsumfunc.__all__
676    "einsum", "einsum_path",
677    # matrixlib.__all__
678    "matrix", "bmat", "asmatrix",
679    # lib._histograms_impl.__all__
680    "histogram", "histogramdd", "histogram_bin_edges",
681    # lib._nanfunctions_impl.__all__
682    "nansum", "nanmax", "nanmin", "nanargmax", "nanargmin", "nanmean", "nanmedian",
683    "nanpercentile", "nanvar", "nanstd", "nanprod", "nancumsum", "nancumprod",
684    "nanquantile",
685    # lib._function_base_impl.__all__
686    "select", "piecewise", "trim_zeros", "copy", "iterable", "percentile", "diff",
687    "gradient", "angle", "unwrap", "sort_complex", "flip", "rot90", "extract", "place",
688    "vectorize", "asarray_chkfinite", "average", "bincount", "digitize", "cov",
689    "corrcoef", "median", "sinc", "hamming", "hanning", "bartlett", "blackman",
690    "kaiser", "trapezoid", "i0", "meshgrid", "delete", "insert", "append",
691    "interp", "quantile",
692    # lib._twodim_base_impl.__all__
693    "diag", "diagflat", "eye", "fliplr", "flipud", "tri", "triu", "tril", "vander",
694    "histogram2d", "mask_indices", "tril_indices", "tril_indices_from", "triu_indices",
695    "triu_indices_from",
696    # lib._shape_base_impl.__all__
697    "column_stack", "dstack", "array_split", "split", "hsplit", "vsplit", "dsplit",
698    "apply_over_axes", "expand_dims", "apply_along_axis", "kron", "tile",
699    "take_along_axis", "put_along_axis", "row_stack",
700    # lib._type_check_impl.__all__
701    "iscomplexobj", "isrealobj", "imag", "iscomplex", "isreal", "nan_to_num", "real",
702    "real_if_close", "typename", "mintypecode", "common_type",
703    # lib._arraysetops_impl.__all__
704    "ediff1d", "intersect1d", "isin", "setdiff1d", "setxor1d", "union1d",
705    "unique", "unique_all", "unique_counts", "unique_inverse", "unique_values",
706    # lib._ufunclike_impl.__all__
707    "fix", "isneginf", "isposinf",
708    # lib._arraypad_impl.__all__
709    "pad",
710    # lib._utils_impl.__all__
711    "get_include", "info", "show_runtime",
712    # lib._stride_tricks_impl.__all__
713    "broadcast_to", "broadcast_arrays", "broadcast_shapes",
714    # lib._polynomial_impl.__all__
715    "poly", "roots", "polyint", "polyder", "polyadd", "polysub", "polymul", "polydiv",
716    "polyval", "poly1d", "polyfit",
717    # lib._npyio_impl.__all__
718    "savetxt", "loadtxt", "genfromtxt", "load", "save", "savez", "savez_compressed",
719    "packbits", "unpackbits", "fromregex",
720    # lib._index_tricks_impl.__all__
721    "ravel_multi_index", "unravel_index", "mgrid", "ogrid", "r_", "c_", "s_",
722    "index_exp", "ix_", "ndenumerate", "ndindex", "fill_diagonal", "diag_indices",
723    "diag_indices_from",
724
725    # __init__.__all__
726    "emath", "show_config", "__version__", "__array_namespace_info__",
727]  # fmt: skip
728
729### Constrained types  (for internal use only)
730# Only use these for functions; never as generic type parameter.
731
732_AnyStr = TypeVar("_AnyStr", LiteralString, str, bytes)
733_AnyShapeT = TypeVar(
734    "_AnyShapeT",
735    tuple[()],  # 0-d
736    tuple[int],  # 1-d
737    tuple[int, int],  # 2-d
738    tuple[int, int, int],  # 3-d
739    tuple[int, int, int, int],  # 4-d
740    tuple[int, int, int, int, int],  # 5-d
741    tuple[int, int, int, int, int, int],  # 6-d
742    tuple[int, int, int, int, int, int, int],  # 7-d
743    tuple[int, int, int, int, int, int, int, int],  # 8-d
744    tuple[int, ...],  # N-d
745)
746_AnyTD64Item = TypeVar("_AnyTD64Item", dt.timedelta, int, None, dt.timedelta | int | None)
747_AnyDT64Arg = TypeVar("_AnyDT64Arg", dt.datetime, dt.date, None)
748_AnyDT64Item = TypeVar("_AnyDT64Item", dt.datetime, dt.date, int, None, dt.date, int | None)
749_AnyDate = TypeVar("_AnyDate", dt.date, dt.datetime)
750_AnyDateOrTime = TypeVar("_AnyDateOrTime", dt.date, dt.datetime, dt.timedelta)
751
752### Type parameters  (for internal use only)
753
754_T = TypeVar("_T")
755_T_co = TypeVar("_T_co", covariant=True)
756_T_contra = TypeVar("_T_contra", contravariant=True)
757_RealT_co = TypeVar("_RealT_co", covariant=True)
758_ImagT_co = TypeVar("_ImagT_co", covariant=True)
759
760_DTypeT = TypeVar("_DTypeT", bound=dtype)
761_DTypeT_co = TypeVar("_DTypeT_co", bound=dtype, default=dtype, covariant=True)
762_FlexDTypeT = TypeVar("_FlexDTypeT", bound=dtype[flexible])
763
764_ArrayT = TypeVar("_ArrayT", bound=ndarray)
765_ArrayT_co = TypeVar("_ArrayT_co", bound=ndarray, default=ndarray, covariant=True)
766_BoolArrayT = TypeVar("_BoolArrayT", bound=NDArray[np.bool])
767_IntegerArrayT = TypeVar("_IntegerArrayT", bound=NDArray[integer])
768_IntegralArrayT = TypeVar("_IntegralArrayT", bound=NDArray[np.bool | integer | object_])
769_FloatingArrayT = TypeVar("_FloatingArrayT", bound=NDArray[floating])
770_FloatingTimedeltaArrayT = TypeVar("_FloatingTimedeltaArrayT", bound=NDArray[floating | timedelta64])
771_ComplexFloatingArrayT = TypeVar("_ComplexFloatingArrayT", bound=NDArray[complexfloating])
772_InexactArrayT = TypeVar("_InexactArrayT", bound=NDArray[inexact])
773_InexactTimedeltaArrayT = TypeVar("_InexactTimedeltaArrayT", bound=NDArray[inexact | timedelta64])
774_NumberArrayT = TypeVar("_NumberArrayT", bound=NDArray[number])
775_NumberCharacterArrayT = TypeVar("_NumberCharacterArrayT", bound=ndarray[Any, dtype[number | character] | dtypes.StringDType])
776_TimedeltaArrayT = TypeVar("_TimedeltaArrayT", bound=NDArray[timedelta64])
777_TimeArrayT = TypeVar("_TimeArrayT", bound=NDArray[datetime64 | timedelta64])
778_ObjectArrayT = TypeVar("_ObjectArrayT", bound=NDArray[object_])
779_BytesArrayT = TypeVar("_BytesArrayT", bound=NDArray[bytes_])
780_StringArrayT = TypeVar("_StringArrayT", bound=ndarray[Any, dtype[str_] | dtypes.StringDType])
781_RealArrayT = TypeVar("_RealArrayT", bound=NDArray[floating | integer | timedelta64 | np.bool | object_])
782_NumericArrayT = TypeVar("_NumericArrayT", bound=NDArray[number | timedelta64 | object_])
783
784_ShapeT = TypeVar("_ShapeT", bound=_Shape)
785_Shape1T = TypeVar("_Shape1T", bound=tuple[int, *tuple[int, ...]])
786_ShapeT_co = TypeVar("_ShapeT_co", bound=_Shape, default=_AnyShape, covariant=True)
787_2DShapeT_co = TypeVar("_2DShapeT_co", bound=_2D, default=_2D, covariant=True)
788_1NShapeT = TypeVar("_1NShapeT", bound=tuple[L[1], *tuple[L[1], ...]])  # (1,) | (1, 1) | (1, 1, 1) | ...
789
790_ScalarT = TypeVar("_ScalarT", bound=generic)
791_ScalarT_co = TypeVar("_ScalarT_co", bound=generic, default=Any, covariant=True)
792_NumberT = TypeVar("_NumberT", bound=number)
793_InexactT = TypeVar("_InexactT", bound=inexact)
794_RealNumberT = TypeVar("_RealNumberT", bound=floating | integer)
795_IntegerT = TypeVar("_IntegerT", bound=integer)
796_NonObjectScalarT = TypeVar("_NonObjectScalarT", bound=np.bool | number | flexible | datetime64 | timedelta64)
797
798_NBit = TypeVar("_NBit", bound=NBitBase, default=Any)  # pyright: ignore[reportDeprecated]
799_NBit1 = TypeVar("_NBit1", bound=NBitBase, default=Any)  # pyright: ignore[reportDeprecated]
800_NBit2 = TypeVar("_NBit2", bound=NBitBase, default=_NBit1)  # pyright: ignore[reportDeprecated]
801
802_ItemT_co = TypeVar("_ItemT_co", default=Any, covariant=True)
803_BoolItemT = TypeVar("_BoolItemT", bound=builtins.bool)
804_BoolItemT_co = TypeVar("_BoolItemT_co", bound=builtins.bool, default=builtins.bool, covariant=True)
805_NumberItemT_co = TypeVar("_NumberItemT_co", bound=complex, default=int | float | complex, covariant=True)
806_InexactItemT_co = TypeVar("_InexactItemT_co", bound=complex, default=float | complex, covariant=True)
807_FlexibleItemT_co = TypeVar(
808    "_FlexibleItemT_co",
809    bound=_CharLike_co | tuple[Any, ...],
810    default=_CharLike_co | tuple[Any, ...],
811    covariant=True,
812)
813_CharacterItemT_co = TypeVar("_CharacterItemT_co", bound=_CharLike_co, default=_CharLike_co, covariant=True)
814_TD64ItemT_co = TypeVar("_TD64ItemT_co", bound=dt.timedelta | int | None, default=dt.timedelta | int | None, covariant=True)
815_DT64ItemT_co = TypeVar("_DT64ItemT_co", bound=dt.date | int | None, default=dt.date | int | None, covariant=True)
816_TD64UnitT = TypeVar("_TD64UnitT", bound=_TD64Unit, default=_TD64Unit)
817_BoolOrIntArrayT = TypeVar("_BoolOrIntArrayT", bound=NDArray[integer | np.bool])
818
819### Type Aliases (for internal use only)
820
821_Falsy: TypeAlias = L[False, 0] | np.bool[L[False]]
822_Truthy: TypeAlias = L[True, 1] | np.bool[L[True]]
823
824_1D: TypeAlias = tuple[int]
825_2D: TypeAlias = tuple[int, int]
826_2Tuple: TypeAlias = tuple[_T, _T]
827
828_ArrayUInt_co: TypeAlias = NDArray[unsignedinteger | np.bool]
829_ArrayInt_co: TypeAlias = NDArray[integer | np.bool]
830_ArrayFloat64_co: TypeAlias = NDArray[floating[_64Bit] | float32 | float16 | integer | np.bool]
831_ArrayFloat_co: TypeAlias = NDArray[floating | integer | np.bool]
832_ArrayComplex128_co: TypeAlias = NDArray[number[_64Bit] | number[_32Bit] | float16 | integer | np.bool]
833_ArrayComplex_co: TypeAlias = NDArray[inexact | integer | np.bool]
834_ArrayNumber_co: TypeAlias = NDArray[number | np.bool]
835_ArrayTD64_co: TypeAlias = NDArray[timedelta64 | integer | np.bool]
836
837_Float64_co: TypeAlias = float | floating[_64Bit] | float32 | float16 | integer | np.bool
838_Complex64_co: TypeAlias = number[_32Bit] | number[_16Bit] | number[_8Bit] | builtins.bool | np.bool
839_Complex128_co: TypeAlias = complex | number[_64Bit] | _Complex64_co
840
841_ToIndex: TypeAlias = SupportsIndex | slice | EllipsisType | _ArrayLikeInt_co | None
842_ToIndices: TypeAlias = _ToIndex | tuple[_ToIndex, ...]
843
844_UnsignedIntegerCType: TypeAlias = type[
845    ct.c_uint8 | ct.c_uint16 | ct.c_uint32 | ct.c_uint64
846    | ct.c_ushort | ct.c_uint | ct.c_ulong | ct.c_ulonglong
847    | ct.c_size_t | ct.c_void_p
848]  # fmt: skip
849_SignedIntegerCType: TypeAlias = type[
850    ct.c_int8 | ct.c_int16 | ct.c_int32 | ct.c_int64
851    | ct.c_short | ct.c_int | ct.c_long | ct.c_longlong
852    | ct.c_ssize_t
853]  # fmt: skip
854_FloatingCType: TypeAlias = type[ct.c_float | ct.c_double | ct.c_longdouble]
855_IntegerCType: TypeAlias = _UnsignedIntegerCType | _SignedIntegerCType
856
857# some commonly used builtin types that are known to result in a
858# `dtype[object_]`, when their *type* is passed to the `dtype` constructor
859# NOTE: `builtins.object` should not be included here
860_BuiltinObjectLike: TypeAlias = (
861    slice | Decimal | Fraction | UUID
862    | dt.date | dt.time | dt.timedelta | dt.tzinfo
863    | tuple[Any, ...] | list[Any] | set[Any] | frozenset[Any] | dict[Any, Any]
864)  # fmt: skip
865
866# Introduce an alias for `dtype` to avoid naming conflicts.
867_dtype: TypeAlias = dtype[_ScalarT]
868
869_ByteOrderChar: TypeAlias = L["<", ">", "=", "|"]
870# can be anything, is case-insensitive, and only the first character matters
871_ByteOrder: TypeAlias = L[
872    "S",                 # swap the current order (default)
873    "<", "L", "little",  # little-endian
874    ">", "B", "big",     # big endian
875    "=", "N", "native",  # native order
876    "|", "I",            # ignore
877]  # fmt: skip
878_DTypeKind: TypeAlias = L[
879    "b",  # boolean
880    "i",  # signed integer
881    "u",  # unsigned integer
882    "f",  # floating-point
883    "c",  # complex floating-point
884    "m",  # timedelta64
885    "M",  # datetime64
886    "O",  # python object
887    "S",  # byte-string (fixed-width)
888    "U",  # unicode-string (fixed-width)
889    "V",  # void
890    "T",  # unicode-string (variable-width)
891]
892_DTypeChar: TypeAlias = L[
893    "?",  # bool
894    "b",  # byte
895    "B",  # ubyte
896    "h",  # short
897    "H",  # ushort
898    "i",  # intc
899    "I",  # uintc
900    "l",  # long
901    "L",  # ulong
902    "q",  # longlong
903    "Q",  # ulonglong
904    "e",  # half
905    "f",  # single
906    "d",  # double
907    "g",  # longdouble
908    "F",  # csingle
909    "D",  # cdouble
910    "G",  # clongdouble
911    "O",  # object
912    "S",  # bytes_ (S0)
913    "a",  # bytes_ (deprecated)
914    "U",  # str_
915    "V",  # void
916    "M",  # datetime64
917    "m",  # timedelta64
918    "c",  # bytes_ (S1)
919    "T",  # StringDType
920]
921_DTypeNum: TypeAlias = L[
922    0,  # bool
923    1,  # byte
924    2,  # ubyte
925    3,  # short
926    4,  # ushort
927    5,  # intc
928    6,  # uintc
929    7,  # long
930    8,  # ulong
931    9,  # longlong
932    10,  # ulonglong
933    23,  # half
934    11,  # single
935    12,  # double
936    13,  # longdouble
937    14,  # csingle
938    15,  # cdouble
939    16,  # clongdouble
940    17,  # object
941    18,  # bytes_
942    19,  # str_
943    20,  # void
944    21,  # datetime64
945    22,  # timedelta64
946    25,  # no type
947    256,  # user-defined
948    2056,  # StringDType
949]
950_DTypeBuiltinKind: TypeAlias = L[0, 1, 2]
951
952_ArrayAPIVersion: TypeAlias = L["2021.12", "2022.12", "2023.12", "2024.12"]
953
954_CastingKind: TypeAlias = L["no", "equiv", "safe", "same_kind", "same_value", "unsafe"]
955
956_OrderKACF: TypeAlias = L["K", "A", "C", "F"] | None
957_OrderACF: TypeAlias = L["A", "C", "F"] | None
958_OrderCF: TypeAlias = L["C", "F"] | None  # noqa: PYI047
959
960_ModeKind: TypeAlias = L["raise", "wrap", "clip"]
961_PartitionKind: TypeAlias = L["introselect"]
962# in practice, only the first case-insensitive character is considered (so e.g.
963# "QuantumSort3000" will be interpreted as quicksort).
964_SortKind: TypeAlias = L[
965    "Q", "quick", "quicksort",
966    "M", "merge", "mergesort",
967    "H", "heap", "heapsort",
968    "S", "stable", "stablesort",
969]
970_SortSide: TypeAlias = L["left", "right"]
971
972_ConvertibleToInt: TypeAlias = SupportsInt | SupportsIndex | _CharLike_co
973_ConvertibleToFloat: TypeAlias = SupportsFloat | SupportsIndex | _CharLike_co
974_ConvertibleToComplex: TypeAlias = SupportsComplex | SupportsFloat | SupportsIndex | _CharLike_co
975_ConvertibleToTD64: TypeAlias = dt.timedelta | int | _CharLike_co | character | number | timedelta64 | np.bool | None
976_ConvertibleToDT64: TypeAlias = dt.date | int | _CharLike_co | character | number | datetime64 | np.bool | None
977
978_NDIterFlagsKind: TypeAlias = L[
979    "buffered",
980    "c_index",
981    "copy_if_overlap",
982    "common_dtype",
983    "delay_bufalloc",
984    "external_loop",
985    "f_index",
986    "grow_inner", "growinner",
987    "multi_index",
988    "ranged",
989    "refs_ok",
990    "reduce_ok",
991    "zerosize_ok",
992]
993_NDIterFlagsOp: TypeAlias = L[
994    "aligned",
995    "allocate",
996    "arraymask",
997    "copy",
998    "config",
999    "nbo",
1000    "no_subtype",
1001    "no_broadcast",
1002    "overlap_assume_elementwise",
1003    "readonly",
1004    "readwrite",
1005    "updateifcopy",
1006    "virtual",
1007    "writeonly",
1008    "writemasked",
1009]
1010
1011_MemMapModeKind: TypeAlias = L[
1012    "readonly", "r",
1013    "copyonwrite", "c",
1014    "readwrite", "r+",
1015    "write", "w+",
1016]
1017
1018_DT64Date: TypeAlias = _HasDateAttributes | L["TODAY", "today", b"TODAY", b"today"]
1019_DT64Now: TypeAlias = L["NOW", "now", b"NOW", b"now"]
1020_NaTValue: TypeAlias = L["NAT", "NaT", "nat", b"NAT", b"NaT", b"nat"]
1021
1022_MonthUnit: TypeAlias = L["Y", "M", b"Y", b"M"]
1023_DayUnit: TypeAlias = L["W", "D", b"W", b"D"]
1024_DateUnit: TypeAlias = L[_MonthUnit, _DayUnit]
1025_NativeTimeUnit: TypeAlias = L["h", "m", "s", "ms", "us", "μs", b"h", b"m", b"s", b"ms", b"us"]
1026_IntTimeUnit: TypeAlias = L["ns", "ps", "fs", "as", b"ns", b"ps", b"fs", b"as"]
1027_TimeUnit: TypeAlias = L[_NativeTimeUnit, _IntTimeUnit]
1028_NativeTD64Unit: TypeAlias = L[_DayUnit, _NativeTimeUnit]
1029_IntTD64Unit: TypeAlias = L[_MonthUnit, _IntTimeUnit]
1030_TD64Unit: TypeAlias = L[_DateUnit, _TimeUnit]
1031_TimeUnitSpec: TypeAlias = _TD64UnitT | tuple[_TD64UnitT, SupportsIndex]
1032
1033### TypedDict's (for internal use only)
1034
1035@type_check_only
1036class _FormerAttrsDict(TypedDict):
1037    object: LiteralString
1038    float: LiteralString
1039    complex: LiteralString
1040    str: LiteralString
1041    int: LiteralString
1042
1043### Protocols (for internal use only)
1044
1045@final
1046@type_check_only
1047class _SupportsLT(Protocol):
1048    def __lt__(self, other: Any, /) -> Any: ...
1049
1050@final
1051@type_check_only
1052class _SupportsLE(Protocol):
1053    def __le__(self, other: Any, /) -> Any: ...
1054
1055@final
1056@type_check_only
1057class _SupportsGT(Protocol):
1058    def __gt__(self, other: Any, /) -> Any: ...
1059
1060@final
1061@type_check_only
1062class _SupportsGE(Protocol):
1063    def __ge__(self, other: Any, /) -> Any: ...
1064
1065@type_check_only
1066class _SupportsFileMethods(SupportsFlush, Protocol):
1067    # Protocol for representing file-like-objects accepted by `ndarray.tofile` and `fromfile`
1068    def fileno(self) -> SupportsIndex: ...
1069    def tell(self) -> SupportsIndex: ...
1070    def seek(self, offset: int, whence: int, /) -> object: ...
1071
1072@type_check_only
1073class _SupportsFileMethodsRW(SupportsWrite[bytes], _SupportsFileMethods, Protocol): ...
1074
1075@type_check_only
1076class _SupportsDLPack(Protocol[_T_contra]):
1077    def __dlpack__(self, /, *, stream: _T_contra | None = None) -> CapsuleType: ...
1078
1079@type_check_only
1080class _HasDType(Protocol[_T_co]):
1081    @property
1082    def dtype(self, /) -> _T_co: ...
1083
1084@type_check_only
1085class _HasRealAndImag(Protocol[_RealT_co, _ImagT_co]):
1086    @property
1087    def real(self, /) -> _RealT_co: ...
1088    @property
1089    def imag(self, /) -> _ImagT_co: ...
1090
1091@type_check_only
1092class _HasTypeWithRealAndImag(Protocol[_RealT_co, _ImagT_co]):
1093    @property
1094    def type(self, /) -> type[_HasRealAndImag[_RealT_co, _ImagT_co]]: ...
1095
1096@type_check_only
1097class _HasDTypeWithRealAndImag(Protocol[_RealT_co, _ImagT_co]):
1098    @property
1099    def dtype(self, /) -> _HasTypeWithRealAndImag[_RealT_co, _ImagT_co]: ...
1100
1101@type_check_only
1102class _HasDateAttributes(Protocol):
1103    # The `datetime64` constructors requires an object with the three attributes below,
1104    # and thus supports datetime duck typing
1105    @property
1106    def day(self) -> int: ...
1107    @property
1108    def month(self) -> int: ...
1109    @property
1110    def year(self) -> int: ...
1111
1112### Mixins (for internal use only)
1113
1114@type_check_only
1115class _RealMixin:
1116    @property
1117    def real(self) -> Self: ...
1118    @property
1119    def imag(self) -> Self: ...
1120
1121@type_check_only
1122class _RoundMixin:
1123    @overload
1124    def __round__(self, /, ndigits: None = None) -> int: ...
1125    @overload
1126    def __round__(self, /, ndigits: SupportsIndex) -> Self: ...
1127
1128@type_check_only
1129class _IntegralMixin(_RealMixin):
1130    @property
1131    def numerator(self) -> Self: ...
1132    @property
1133    def denominator(self) -> L[1]: ...
1134
1135    def is_integer(self, /) -> L[True]: ...
1136
1137### Public API
1138
1139__version__: Final[LiteralString] = ...
1140
1141e: Final[float] = ...
1142euler_gamma: Final[float] = ...
1143pi: Final[float] = ...
1144inf: Final[float] = ...
1145nan: Final[float] = ...
1146little_endian: Final[builtins.bool] = ...
1147False_: Final[np.bool[L[False]]] = ...
1148True_: Final[np.bool[L[True]]] = ...
1149newaxis: Final[None] = None
1150
1151# not in __all__
1152__NUMPY_SETUP__: Final[L[False]] = False
1153__numpy_submodules__: Final[set[LiteralString]] = ...
1154__former_attrs__: Final[_FormerAttrsDict] = ...
1155__future_scalars__: Final[set[L["bytes", "str", "object"]]] = ...
1156__array_api_version__: Final[L["2024.12"]] = "2024.12"
1157test: Final[PytestTester] = ...
1158
1159@type_check_only
1160class _DTypeMeta(type):
1161    @property
1162    def type(cls, /) -> type[generic] | None: ...
1163    @property
1164    def _abstract(cls, /) -> bool: ...
1165    @property
1166    def _is_numeric(cls, /) -> bool: ...
1167    @property
1168    def _parametric(cls, /) -> bool: ...
1169    @property
1170    def _legacy(cls, /) -> bool: ...
1171
1172@final
1173class dtype(Generic[_ScalarT_co], metaclass=_DTypeMeta):
1174    names: tuple[builtins.str, ...] | None
1175    def __hash__(self) -> int: ...
1176
1177    # `None` results in the default dtype
1178    @overload
1179    def __new__(
1180        cls,
1181        dtype: type[float64 | ct.c_double] | _Float64Codes | _DoubleCodes | None,
1182        align: builtins.bool = False,
1183        copy: builtins.bool = False,
1184        *,
1185        metadata: dict[builtins.str, Any] = ...
1186    ) -> dtype[float64]: ...
1187
1188    # Overload for `dtype` instances, scalar types, and instances that have a
1189    # `dtype: dtype[_ScalarT]` attribute
1190    @overload
1191    def __new__(
1192        cls,
1193        dtype: _DTypeLike[_ScalarT],
1194        align: builtins.bool = False,
1195        copy: builtins.bool = False,
1196        *,
1197        metadata: dict[builtins.str, Any] = ...,
1198    ) -> dtype[_ScalarT]: ...
1199
1200    # Builtin types

Showing the first 1,200 of 6203 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai