[Numpy-discussion] hstack(arr_Int32, arr_float32) fails because of casting rules

Sebastian Haase haase at msg.ucsf.edu
Thu Aug 24 22:59:19 CDT 2006


Travis Oliphant wrote:
> Sebastian Haase wrote:
>> On Thursday 24 August 2006 17:28, Travis Oliphant wrote:
>>   
>> Are you saying the  ufunc-rules  would convert "int32-float32" to float64  and 
>> hence make my code "just work" !?
>>   
> Yes.  That's what I'm saying (but you would get float64 out --- but if 
> you didn't want that then you would have to be specific).
> 
>> And why are there two sets of rules ?
>>   
> Because there are two modules (multiarray and umath) where the 
> functionality is implemented.
> 
>> Are the Numeric rules used at many places ?
>>   
> Not that many.  I did abstract the notion to a C-API:  
> PyArray_ConvertToCommonType and implemented the 
> scalars-don't-cause-upcasting part of the ufunc rules in that code.   
> But, I followed the old-style Numeric coercion rules for the rest of it 
> (because I was adapting Numeric).
> 
> Right now, unless there are strong objections, I'm leaning to changing 
> that so that the same coercion rules are used whenever a common type is 
> needed. 

If you mean keeping the ufunc rules (which seem more liberal, fix my 
problem ;-) and might make using float32 in general more painless) - I 
would be all for it ...   simplifying is always good in the long term ...

Cheers,
Sebastian

> 
> It would not be that difficult of a change.







More information about the Numpy-discussion mailing list