[Numpy-discussion] Handling of numpy.power(0, <something>)

Christian Heimes lists at cheimes.de
Thu Feb 28 15:16:23 EST 2008


Stuart Brorson wrote:
> I have been poking at the limits of NumPy's handling of powers of
> zero.   I find some results which are disturbing, at least to me.
> Here they are:

[SNIPP]

Please checkout Mark Dickinson's and my trunk-math branch of Python 2.6.
We have put lots of effort into fixing edge cases of floats, math and
cmath functions. The return values are either based on the latest
revision of IEEE 754 or the last public draft of the C99 standard (1124,
Annex F and G).

For pow the C99 says:

>>> math.pow(0, 0)
1.0
>>> math.pow(0, 1)
0.0
[30859 refs]
>>> math.pow(0, float("inf"))
0.0
>>> math.pow(0, float("nan"))
nan
>>> math.pow(0, -1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: math domain error

Christian




More information about the NumPy-Discussion mailing list