[Python-Dev] math.hypot, complex.__abs__, and documentation
David DiCato
ddicato at microsoft.com
Tue Feb 16 22:19:00 CET 2010
I have a minor concern about certain corner cases with math.hypot and complex.__abs__, namely when one component is infinite and one is not a number. If we execute the following code:
import math
inf = float('inf')
nan = float('nan')
print math.hypot(inf, nan)
print abs(complex(nan, inf))
... then we see that 'inf' is printed in both cases. The standard library tests (for example, test_cmath.py:test_abs()) seem to test for this behavior as well, and FWIW, I personally agree with this convention. However, the math module's documentation for both 2.6 and 3.1 states, "All functions return a quiet NaN if at least one of the args is NaN."
math.pow(1.0, nan) is another such exception to the rule. Perhaps the documentation should be updated to reflect this.
Thanks,
- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20100216/57c5328b/attachment.htm>
More information about the Python-Dev
mailing list