[Numpy-discussion] type coercion question

Fernando Perez Fernando.Perez at colorado.edu
Wed Mar 31 09:58:05 EST 2004


Chris Barker wrote:
> On Mar 31, 2004, at 7:39 AM, Perry Greenfield wrote:
> 
>>Just to summarize what I see as acceptable choices:
>>
>>1) ints promote to Float32 (current behavior)
>>2) ints promote to Float64
>>3) Int32 promotes to Float64, lesser ints promote to Float32 (Numeric
>>behavior)
> 
> 
> +1 on (2)
> 
> I want math.cos(x) to give the same answer as numarray.cos( array( (x) 
> ) ) as much as possible. I like that Numarray does not do as much 
> auto-upcasting as Numeric, but if I want to control the size of my data 
> arrays, I'm not going to be passing an int into a floating point 
> function. i.e, I can always do:
> 
> cos( array( (x), Float32 ) )
> 
> Then I would want the result to be a Float32

+1 on (2) as well, based on a similar reasoning to Chris (who saved me the 
time of typing it up cleanly :)

Cheers,

f





More information about the NumPy-Discussion mailing list