Add smallest_normal and smallest_subnormal attributes to finfo
Good afternoon, Given the discussions happened in the Data API consortium when looking into the attributes of `finfo` used in the wild, we found that `tiny` is used regularly but in a good amount of cases not for its intended purpose but rather as "just give me a small number". Following this we are proposing the addition of `smallest_normal` and `smallest_subnormal` attributes. Personally, I think that the `tiny` name is a little bit odd and misleading, so it will be great to leave that as an alias but have a clear name in this class. Right now the PR: https://github.com/numpy/numpy/pull/18536 has all the changes and all the values added were checked against IEEE-754 standard. One of the main concerns is the support of subnormal numbers in certain architectures, where the values can't be calculated accurately. Given the state of the discussion, we don't know if the best alternative is to not add the `smallest_subnormal` attribute and just add the `smallest_number` attribute as an alias to `tiny`. We open this to discussion to see what way we can go in order to get this PR merged. *Stephannie Jimenez Gacha*Software developer *Quansight* | Your Data Experts w: www.quansight.com e: sgacha@quansight.com <https://www.linkedin.com/company/quansight> <https://twitter.com/quansightai>
Hi all, We just merged the PR to add `np.finfo.smallest_normal` and `np.finfo.smallest_subnormal` to `np.finfo` (the floating point DType information object): * smallest_normal: - An alias for `np.finfo.tiny` - The smallest "normal". I.e. the smallest number larger than zero that has full precision. * smallest_subnormal: - Equivalent to `np.nextafter(0., 1.)` - The smallest subnormal/denormal number. I.e. the smallest representable number larger than zero. Please don't hesitate to comment if you have any thoughts on the API addition. Cheers, Sebastian On Wed, 2021-04-21 at 17:44 -0500, Stephannie Jiménez Gacha wrote:
Good afternoon,
Given the discussions happened in the Data API consortium when looking into the attributes of `finfo` used in the wild, we found that `tiny` is used regularly but in a good amount of cases not for its intended purpose but rather as "just give me a small number". Following this we are proposing the addition of `smallest_normal` and `smallest_subnormal` attributes. Personally, I think that the `tiny` name is a little bit odd and misleading, so it will be great to leave that as an alias but have a clear name in this class.
Right now the PR: https://github.com/numpy/numpy/pull/18536 has all the changes and all the values added were checked against IEEE-754 standard. One of the main concerns is the support of subnormal numbers in certain architectures, where the values can't be calculated accurately. Given the state of the discussion, we don't know if the best alternative is to not add the `smallest_subnormal` attribute and just add the `smallest_number` attribute as an alias to `tiny`.
We open this to discussion to see what way we can go in order to get this PR merged.
*Stephannie Jimenez Gacha*Software developer
*Quansight* | Your Data Experts
w: www.quansight.com e: sgacha@quansight.com <https://www.linkedin.com/company/quansight> <https://twitter.com/quansightai> _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
participants (2)
-
Sebastian Berg
-
Stephannie Jiménez Gacha