[Numpy-discussion] Old tickets

Benjamin Root ben.root@ou....
Wed Mar 30 16:26:40 CDT 2011


On Wed, Mar 30, 2011 at 2:37 PM, Bruce Southey <bsouthey@gmail.com> wrote:

> Hi,
> This followup on tickets that I had previously indicated. So I want to
> thank Mark, Ralph and any people for going over those!
>
> For those that I followed I generally agreed with the outcome.
>
> Ticket 301: 'Make power and divide return floats from int inputs (like
> true_divide)'
> http://projects.scipy.org/numpy/ticket/301
> Invalid because the output dtype is the same as the input dtype unless
> you override using the dtype argument:
>  >>> np.power(3, 1, dtype=np.float128).dtype
> dtype('float128')
> Alternatively return a float and indicate in the docstring that the
> output dtype can be changed.
>
>
FWIW,

Just thought I'd note (on a python 2.6 system):

>>> import numpy as np
>>> a = np.array([1, 2, 3, 4])
>>> a.dtype
dtype('int32')
>>> 2 / a
array([2, 1, 0, 0])
>>> from __future__ import division
>>> 2 / a
array([ 2.        ,  1.        ,  0.66666667,  0.5       ])

So, numpy already does this when true division is imported (and therefore
consistent with whatever the python environment does), and python currently
also returns integers for exponentials when both inputs are integers.

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110330/f4e9eb6c/attachment.html 


More information about the NumPy-Discussion mailing list