[Numpy-discussion] What type should / return in python 3k when applied to two integer types?
Christopher Barker
Chris.Barker at noaa.gov
Thu Aug 27 17:22:39 EDT 2009
Robert Kern wrote:
> On Thu, Aug 27, 2009 at 12:43, Charles R
> Harris<charlesr.harris at gmail.com> wrote:
>> In [3]: floor_divide(x,y).dtype
>> Out[3]: dtype('float64')
>
> Ewww. It should be an appropriate integer type. Probably whatever x*y is.
+1 if you are working with integers, you should get integers, because
that's probably what you want. -- they can overflow, etc. anyway, so
buyer beware!
In [7]: x.dtype
Out[7]: dtype('int64')
In [8]: y.dtype
Out[8]: dtype('uint64')
In [9]: (x * y).dtype
Out[9]: dtype('float64')
hmmm -- I thought we had removed this kind of silent upcasting
(particularly int-> float), but I guess when you mix two types, numpy
has to choose something!
In any case, x/y should probably return the same type as x*y.
By the way -- is there something about py3k that changes all this? Or is
this just an opportunity to perhaps make some backward-incompatible
changes to numpy?
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the NumPy-Discussion
mailing list