[Numpy-discussion] Fixed scalar coercion model in NumPy

Travis Oliphant oliphant at ee.byu.edu
Mon Mar 26 17:30:25 EDT 2007


Perry Greenfield wrote:

>Great!
>
>On Mar 26, 2007, at 4:52 PM, Travis Oliphant wrote:
>
>  
>
>>I've finally made the changes to fix the scalar coercion model  
>>problems
>>in NumPy 1.0.1
>>
>>Now, scalar coercion rules only apply when involved types are of the
>>same basic "kind".
>>    
>>

Actually, the rule is better stated.  The scalar coercion rules apply 
when involved types are of the same basic "kind" or if the scalar is of 
"lesser" kind than the array.

Thus,

array([1,2,3],float32)*10    produces a float32 array
array([1,2,3],float32)*10.0  produces a float32 array
array([1,2,3],float32)*10.0j produces a complex128 array

-Travis




More information about the NumPy-Discussion mailing list