[Numpy-discussion] ndarray special methods should raise NotImplemented instead of TypeError

Charles R Harris charlesr.harris@gmail....
Sun Mar 13 17:17:23 CDT 2011


On Sun, Mar 13, 2011 at 3:53 PM, Hoyt Koepke <hoytak@stat.washington.edu>wrote:

> > You can also define __array_priority__  in your class. If your class
> isn't a
> > subclass, then numpy will always call your class methods whether or not
> your
> > class is on the right or left. Sounds like you don't want to sublass
> ndarray
> > here so that should work.
>
> Excellent!  This sounds like exactly what I was hoping for.  I assume
> in my case, I just need __array_priority__ > 10 to gain priority over
> a matrix (from reading
> http://docs.scipy.org/doc/numpy/reference/arrays.classes.html).  Is
> that correct?
>
>
If you aren't a subclass you just need to define it. I don't know if that is
documented anywhere outside the C source though. I just set it to zero in
the polynomial template in numpy.polynomial.polytemplate.py


Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110313/a682c62f/attachment.html 


More information about the NumPy-Discussion mailing list