[Numpy-discussion] bug in oldnumeric.ma
Wed May 7 15:38:22 CDT 2008
2008/5/7 Pierre GM <email@example.com>:
> Yes, there is a problem with ma.power: masking negative data should be
> restricted to the case of an exponent between -1. and 1. only, don't you
> think ?
No, there's a problem with any fractional exponent (with even
denominator): x**(3/2) == (x**3)**(1/2). And of course in a
floating-point world, you can't really ask whether the denominator is
even or not. So any non-integer power is trouble.
The draconian approach would be to simply disallow negative numbers to
be raised to exponents of type float, but that's going to annoy a lot
of people who have integers which happen to be represented in floats.
(Representing integers in floats is exact up to some fairly large
value.) So the first question is "how do we recognize floats with
integer values?". Unfortunately that's not the real problem. The real
problem is "how do we predict when power() is going to produce a NaN?"
More information about the Numpy-discussion