Skip to content

Commit 34a9039

Browse files
author
Bas van Beek
committed
MAINT: Update the np.finfo annotations
Reflect the `finfo` changes, made in numpy#18536, in the classes' type annotations.
1 parent 8365e3a commit 34a9039

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

numpy/__init__.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3810,7 +3810,11 @@ class finfo(Generic[_FloatType]):
38103810
nmant: int
38113811
precision: int
38123812
resolution: _FloatType
3813-
tiny: _FloatType
3813+
smallest_subnormal: _FloatType
3814+
@property
3815+
def smallest_normal(self) -> _FloatType: ...
3816+
@property
3817+
def tiny(self) -> _FloatType: ...
38143818

38153819
# NOTE: Not technically a property, but this is the only way we can
38163820
# access the precision of the underlying float

numpy/core/getlimits.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class MachArLike(Generic[_NBit]):
2323
huge: floating[Any],
2424
tiny: floating[Any],
2525
ibeta: int,
26+
smallest_subnormal: None | floating[Any] = ...,
2627
# Expand `**kwargs` into keyword-only arguments
2728
machep: int,
2829
negep: int,
@@ -33,6 +34,8 @@ class MachArLike(Generic[_NBit]):
3334
irnd: int,
3435
ngrd: int,
3536
) -> None: ...
37+
@property
38+
def smallest_subnormal(self) -> NDArray[floating[_NBit]]: ...
3639
eps: NDArray[floating[_NBit]]
3740
epsilon: NDArray[floating[_NBit]]
3841
epsneg: NDArray[floating[_NBit]]
@@ -48,6 +51,7 @@ class MachArLike(Generic[_NBit]):
4851
ngrd: int
4952
precision: int
5053
resolution: NDArray[floating[_NBit]]
54+
smallest_normal: NDArray[floating[_NBit]]
5155
tiny: NDArray[floating[_NBit]]
5256
title: str
5357
xmax: NDArray[floating[_NBit]]

numpy/typing/tests/data/reveal/getlimits.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
reveal_type(finfo_f8.precision) # E: int
3535
reveal_type(finfo_f8.resolution) # E: {float64}
3636
reveal_type(finfo_f8.tiny) # E: {float64}
37+
reveal_type(finfo_f8.smallest_normal) # E: {float64}
38+
reveal_type(finfo_f8.smallest_subnormal) # E: {float64}
3739
reveal_type(finfo_f8.machar) # E: MachArLike[numpy.typing._64Bit]
3840

3941
reveal_type(np.iinfo(i)) # E: iinfo[{int_}]
@@ -56,6 +58,8 @@
5658
reveal_type(machar_f4.tiny) # E: numpy.ndarray[Any, numpy.dtype[{float32}]]
5759
reveal_type(machar_f4.xmax) # E: numpy.ndarray[Any, numpy.dtype[{float32}]]
5860
reveal_type(machar_f4.xmin) # E: numpy.ndarray[Any, numpy.dtype[{float32}]]
61+
reveal_type(machar_f4.smallest_subnormal) # E: numpy.ndarray[Any, numpy.dtype[{float32}]]
62+
reveal_type(machar_f4.smallest_normal) # E: numpy.ndarray[Any, numpy.dtype[{float32}]]
5963
reveal_type(machar_f4.iexp) # E: int
6064
reveal_type(machar_f4.irnd) # E: int
6165
reveal_type(machar_f4.it) # E: int

0 commit comments

Comments
 (0)