codekingpro/portable-devtools
115k
1from functools import cached_property
2from types import GenericAlias
3from typing import Final, Generic, Self, overload
4from typing_extensions import TypeVar
5
6import numpy as np
7from numpy._typing import (
8 _CLongDoubleCodes,
9 _Complex64Codes,
10 _Complex128Codes,
11 _DTypeLike,
12 _Float16Codes,
13 _Float32Codes,
14 _Float64Codes,
15 _Int8Codes,
16 _Int16Codes,
17 _Int32Codes,
18 _Int64Codes,
19 _IntPCodes,
20 _LongDoubleCodes,
21 _UInt8Codes,
22 _UInt16Codes,
23 _UInt32Codes,
24 _UInt64Codes,
25)
26
27__all__ = ["finfo", "iinfo"]
28
29###
30
31_IntegerT_co = TypeVar("_IntegerT_co", bound=np.integer, default=np.integer, covariant=True)
32_FloatingT_co = TypeVar("_FloatingT_co", bound=np.floating, default=np.floating, covariant=True)
33
34###
35
36class iinfo(Generic[_IntegerT_co]):
37 dtype: np.dtype[_IntegerT_co]
38 bits: Final[int]
39 kind: Final[str]
40 key: Final[str]
41
42 @property
43 def min(self, /) -> int: ...
44 @property
45 def max(self, /) -> int: ...
46
47 #
48 @overload
49 def __init__(self, /, int_type: _IntegerT_co | _DTypeLike[_IntegerT_co]) -> None: ...
50 @overload
51 def __init__(self: iinfo[np.int_], /, int_type: _IntPCodes | type[int] | int) -> None: ...
52 @overload
53 def __init__(self: iinfo[np.int8], /, int_type: _Int8Codes) -> None: ...
54 @overload
55 def __init__(self: iinfo[np.uint8], /, int_type: _UInt8Codes) -> None: ...
56 @overload
57 def __init__(self: iinfo[np.int16], /, int_type: _Int16Codes) -> None: ...
58 @overload
59 def __init__(self: iinfo[np.uint16], /, int_type: _UInt16Codes) -> None: ...
60 @overload
61 def __init__(self: iinfo[np.int32], /, int_type: _Int32Codes) -> None: ...
62 @overload
63 def __init__(self: iinfo[np.uint32], /, int_type: _UInt32Codes) -> None: ...
64 @overload
65 def __init__(self: iinfo[np.int64], /, int_type: _Int64Codes) -> None: ...
66 @overload
67 def __init__(self: iinfo[np.uint64], /, int_type: _UInt64Codes) -> None: ...
68 @overload
69 def __init__(self, /, int_type: str) -> None: ...
70
71 #
72 @classmethod
73 def __class_getitem__(cls, item: object, /) -> GenericAlias: ...
74
75class finfo(Generic[_FloatingT_co]):
76 dtype: np.dtype[_FloatingT_co] # readonly
77 eps: _FloatingT_co # readonly
78 _radix: _FloatingT_co # readonly
79 smallest_normal: _FloatingT_co # readonly
80 smallest_subnormal: _FloatingT_co # readonly
81 max: _FloatingT_co # readonly
82 min: _FloatingT_co # readonly
83
84 _fmt: str | None # `__str__` cache
85 _repr: str | None # `__repr__` cache
86
87 bits: Final[int]
88 maxexp: Final[int]
89 minexp: Final[int]
90 nmant: Final[int]
91 precision: Final[int]
92
93 @classmethod
94 def __class_getitem__(cls, item: object, /) -> GenericAlias: ...
95
96 #
97 @overload
98 def __new__(cls, dtype: _FloatingT_co | _DTypeLike[_FloatingT_co]) -> Self: ...
99 @overload
100 def __new__(cls, dtype: _Float16Codes) -> finfo[np.float16]: ...
101 @overload
102 def __new__(cls, dtype: _Float32Codes | _Complex64Codes | _DTypeLike[np.complex64]) -> finfo[np.float32]: ...
103 @overload
104 def __new__(cls, dtype: _Float64Codes | _Complex128Codes | type[complex] | complex) -> finfo[np.float64]: ...
105 @overload
106 def __new__(cls, dtype: _LongDoubleCodes | _CLongDoubleCodes | _DTypeLike[np.clongdouble]) -> finfo[np.longdouble]: ...
107 @overload
108 def __new__(cls, dtype: str) -> finfo: ...
109
110 #
111 @cached_property
112 def epsneg(self, /) -> _FloatingT_co: ...
113 @cached_property
114 def resolution(self, /) -> _FloatingT_co: ...
115 @cached_property
116 def machep(self, /) -> int: ...
117 @cached_property
118 def negep(self, /) -> int: ...
119 @cached_property
120 def nexp(self, /) -> int: ...
121 @cached_property
122 def iexp(self, /) -> int: ...
123 @cached_property
124 def tiny(self, /) -> _FloatingT_co: ...
125 