getlimits.pyi 3.7 KB

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