[Python-ideas] PEP 485: A Function for testing approximate equality

Ethan Furman ethan at stoneleaf.us
Fri Jan 23 18:12:26 CET 2015

On 01/23/2015 07:36 AM, Antoine Pitrou wrote:
> On Thu, 22 Jan 2015 16:40:14 -0800 Chris Barker wrote:
>> Expected Uses
>> =============
>> The primary expected use case is various forms of testing -- "are the
>> results computed near what I expect as a result?" This sort of test
>> may or may not be part of a formal unit testing suite.
> I don't think the proposal fits the bill. For testing you want a
> function that is both 1) quite rigorous (i.e. checks equality within a
> defined number of ulps) 2) handles all special cases in a useful way
> (i.e. zeros, including distinguishing between positive and negative
> zeros, infinities, NaNs etc.).

I disagree -- this function is not meant for mathematicians, but for the non-maths person who needs something that
works.  Will there be situations where it doesn't work?  Certainly.  Will they be surprising?  Possibly.

On the other hand, I was very surprised the first time an bytes object gave me an integer and not a byte.

> As someone who wrote such a function for Numba, what you're proposing
> would not be a suitable replacement.

This isn't for Numba, SciPy, or NumPy.  It's to help those who don't use/need those products, but still have some light
floating point work to do.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150123/50f93000/attachment.sig>

More information about the Python-ideas mailing list