[Numpy-discussion] Request for clarification from Travis

Travis E. Oliphant oliphant@enthought....
Thu Jun 26 02:50:03 CDT 2008


> Yes, but it is directed at the interpreter, which will raise a 
> TypeError if needed. But the interpreter doesn't know that some 
> generic function might return NotImplemented and wouldn't know what to 
> do if it did. What the user should see when they call something like 
> right_shift(a,b) and it fails is an exception, they shouldn't have to 
> check the return value
Yes, you are right.   So, the questions is how to handle this correctly.
>
> I think what you want is that subtypes of ndarray can override some 
> ufuncs so that, for instance, right_shift() should interpret itself as 
> a call to arg2.__rrshift__ if it exists, even if it isn't called 
> through the interpreter friendly slot function >>. Is that correct? If 
> so, I would rather have an explicit overload flag in the subtype so 
> that the ufunc can easily do the right thing.
So, how would this overload flag work and how would a subtype set it?   
Would this be a per-instance flag in the FLAGS field? 
>  
> I can't find __array_priority__ in your book, what exactly does it imply?
The subtype with the largest priority wins in any decision about which 
subtype to create during operations involving more than one subtype 
(like adding a matrix to an array --- what should be returned?).

-Travis



More information about the Numpy-discussion mailing list