[Numpy-discussion] Scalar coercion

Travis Oliphant oliphant@ee.byu....
Thu Mar 1 17:23:05 CST 2007


Robert Kern wrote:

>Travis Oliphant wrote:
>
>  
>
>>So the question is:  Do we keep the current behavior or change the 
>>behavior to be more consistent with numarray.  My current preference is 
>>to change the behavior so it is more consistent with numarray (even 
>>though it's actually not going to be trivial to do that).
>>    
>>
>
>The current behavior is very obscure and almost never the behavior that one
>desires. Indeed, the first time it came up, you seemed to think it was a bug
>earlier in the thread before (presumably) you went into the code and
>rediscovered the justification.
>  
>

What I discovered is that there wasn't really a justification at all, 
except ease in coding using the current ufunc selection mechanism.

It's just that the code that makes the mixed scalar / array coercion do 
the right thing in the case where both are the same type does not handle 
the mixed type correctly.

There are really two places in the code where this is handled.  One is 
in the ufunc code where the "right" 1-d loop is determined and the 
second is in the call PyArray_ConvertToCommonType.

The mechanisms used for determining the types of the outputs are coded 
differently in each case. 

So, I'm going to try and change this for the 1.0.2 release.   It might 
take me a little bit, so if anybody sees a way to do it, feel free to 
chime in.   I'm probably missing something obvious.

-Travis



More information about the Numpy-discussion mailing list