[Numpy-discussion] What type should / return in python 3k when applied to two integer types?
Charles R Harris
charlesr.harris@gmail....
Thu Aug 27 21:11:53 CDT 2009
On Thu, Aug 27, 2009 at 4:21 PM, Robert Kern <robert.kern@gmail.com> wrote:
> On Thu, Aug 27, 2009 at 15:13, Christopher Barker<Chris.Barker@noaa.gov>
> wrote:
> > Charles R Harris wrote:
> >> I also intend to make it work with
> >>
> >> from future import division
> >
> > doesn't already?
> >
> > In [3]: from __future__ import division
> >
> > In [5]: 3 / 4
> > Out[5]: 0.75
> >
> > In [6]: import numpy as np
> >
> > In [7]: np.array(3) / np.array(4)
> > Out[7]: 0.75
> >
> > In [8]: np.array(3) // np.array(4)
> > Out[8]: 0
>
> Yes, the support for that feature is already there.
>
> >> I've also considered making that import the default for numpy
> >
> > I'd like that, but it is a bit radical --
>
> I don't think so. The policy just affects modules inside numpy, not
> users of numpy.
>
If we go to returning doubles we will have a backward compatibility problem
because the current floor_divide returns float32 for short ints. I see three
options here.
1) Leave true_divide as is.
2) Leave true_divide as is, introduce slash_divide that always returns
doubles.
3) Change true_divide to always return doubles.
None of these options involve much more that a short edit of of the
generate_umath.py module.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090827/4fbd064f/attachment.html
More information about the NumPy-Discussion
mailing list