diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2021-07-27 09:36:24 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-27 09:36:24 -0600 |
commit | 2f782a2f1afa1b25ffacb3ca1ffdbbab0abc1504 (patch) | |
tree | 4c8fb638e6faa5b782e5d5dfb4775fae6fd2855a /numpy | |
parent | b908da64dd4fa8dc70932f51202f9701db4cc868 (diff) | |
parent | 34a9039563c4055dfe6462ff7ed40fab3fc32d90 (diff) | |
download | numpy-2f782a2f1afa1b25ffacb3ca1ffdbbab0abc1504.tar.gz |
Merge pull request #19540 from BvB93/getlimits
MAINT: Update the `np.finfo` annotations
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/__init__.pyi | 6 | ||||
-rw-r--r-- | numpy/core/getlimits.pyi | 4 | ||||
-rw-r--r-- | numpy/typing/tests/data/reveal/getlimits.py | 4 |
3 files changed, 13 insertions, 1 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 5cef4639b..0c6ac34f9 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -3828,7 +3828,11 @@ class finfo(Generic[_FloatType]): nmant: int precision: int resolution: _FloatType - tiny: _FloatType + smallest_subnormal: _FloatType + @property + def smallest_normal(self) -> _FloatType: ... + @property + def tiny(self) -> _FloatType: ... # NOTE: Not technically a property, but this is the only way we can # access the precision of the underlying float diff --git a/numpy/core/getlimits.pyi b/numpy/core/getlimits.pyi index 983d05f36..ca22e18f7 100644 --- a/numpy/core/getlimits.pyi +++ b/numpy/core/getlimits.pyi @@ -23,6 +23,7 @@ class MachArLike(Generic[_NBit]): huge: floating[Any], tiny: floating[Any], ibeta: int, + smallest_subnormal: None | floating[Any] = ..., # Expand `**kwargs` into keyword-only arguments machep: int, negep: int, @@ -33,6 +34,8 @@ class MachArLike(Generic[_NBit]): irnd: int, ngrd: int, ) -> None: ... + @property + def smallest_subnormal(self) -> NDArray[floating[_NBit]]: ... eps: NDArray[floating[_NBit]] epsilon: NDArray[floating[_NBit]] epsneg: NDArray[floating[_NBit]] @@ -48,6 +51,7 @@ class MachArLike(Generic[_NBit]): ngrd: int precision: int resolution: NDArray[floating[_NBit]] + smallest_normal: NDArray[floating[_NBit]] tiny: NDArray[floating[_NBit]] title: str xmax: NDArray[floating[_NBit]] diff --git a/numpy/typing/tests/data/reveal/getlimits.py b/numpy/typing/tests/data/reveal/getlimits.py index e5657f809..e12723bfe 100644 --- a/numpy/typing/tests/data/reveal/getlimits.py +++ b/numpy/typing/tests/data/reveal/getlimits.py @@ -34,6 +34,8 @@ reveal_type(finfo_f8.nmant) # E: int reveal_type(finfo_f8.precision) # E: int reveal_type(finfo_f8.resolution) # E: {float64} reveal_type(finfo_f8.tiny) # E: {float64} +reveal_type(finfo_f8.smallest_normal) # E: {float64} +reveal_type(finfo_f8.smallest_subnormal) # E: {float64} reveal_type(finfo_f8.machar) # E: MachArLike[numpy.typing._64Bit] reveal_type(np.iinfo(i)) # E: iinfo[{int_}] @@ -56,6 +58,8 @@ reveal_type(machar_f4.resolution) # E: numpy.ndarray[Any, numpy.dtype[{float32} reveal_type(machar_f4.tiny) # E: numpy.ndarray[Any, numpy.dtype[{float32}]] reveal_type(machar_f4.xmax) # E: numpy.ndarray[Any, numpy.dtype[{float32}]] reveal_type(machar_f4.xmin) # E: numpy.ndarray[Any, numpy.dtype[{float32}]] +reveal_type(machar_f4.smallest_subnormal) # E: numpy.ndarray[Any, numpy.dtype[{float32}]] +reveal_type(machar_f4.smallest_normal) # E: numpy.ndarray[Any, numpy.dtype[{float32}]] reveal_type(machar_f4.iexp) # E: int reveal_type(machar_f4.irnd) # E: int reveal_type(machar_f4.it) # E: int |