[Numpy-discussion] What type should / return in python 3k when applied to two integer types?
Thu Aug 27 16:22:39 CDT 2009
Robert Kern wrote:
> On Thu, Aug 27, 2009 at 12:43, Charles R
> Harris<email@example.com> wrote:
>> In : floor_divide(x,y).dtype
>> Out: 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
In : x.dtype
In : y.dtype
In : (x * y).dtype
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?
Christopher Barker, Ph.D.
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
More information about the NumPy-Discussion