On Feb 18, 2014 11:55 AM, "Robert Kern" <robert.k...@gmail.com> wrote:
>
> On Tue, Feb 18, 2014 at 9:51 AM, Sturla Molden <sturla.mol...@gmail.com>
wrote:
> > Charles R Harris <charlesr.har...@gmail.com> wrote:
> >> This is apropos issue #899 <<a
> >> href="https://github.com/numpy/numpy/issues/899";>
https://github.com/numpy/numpy/issues/899</a>>,
> >> where it is suggested that power promote integers to float. That sounds
> >> reasonable to me, but such a change in behavior makes it a bit iffy.
> >>
> >> Thoughts?
> >
> > Numpy should do the same as Python does.
>
> That's problematic because Python's behavior is value dependent.
>
> Python 3.3.1 (default, May 16 2013, 17:20:13)
> [GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on
darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> 2 ** 2
> 4
> >>> 2 ** -2
> 0.25
>
> 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.
> Generally, we try to make ufuncs return types that are predictable
> from the types of the operands, not the values of the operands.
>
> I am -1 on the proposal to make power(x:int, y:int) always return a
> float. It is usually trivial to just make the exponent a float if one
> wants a float returned. Or we could introduce an fpow() that always
> coerces the inputs to the best inexact type.

What about making it floats for int types but int for uint types?
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to