[Numpy-discussion] Proposal to make power return float, and other such things.
robert.kern at gmail.com
Tue Feb 18 06:25:18 EST 2014
On Tue, Feb 18, 2014 at 11:19 AM, Sturla Molden <sturla.molden at gmail.com> wrote:
> Robert Kern <robert.kern at gmail.com> wrote:
>> That's fine if you only have one value for each operand. When you have
>> multiple values for each operand, say an exponent array containing
>> both positive and negative integers, that becomes a problem.
> I don't really see why. If you have a negative integer in there you get a
> float array returned, otherwise it stays integer.
We don't do this for any other ufunc.
>> Generally, we try to make ufuncs return types that are predictable
>> from the types of the operands, not the values of the operands.
> Isn't that unpractical in this case? Who cares if the power operator
> behaves as an ufunc?
We're talking about numpy.power(), not just ndarray.__pow__(). The
equivalence of the two is indeed an implementation detail, but I do
think that it is useful to maintain the equivalence. If we didn't, it
would be the only exception, to my knowledge.
More information about the NumPy-Discussion