[Numpy-discussion] ndarray special methods should raise NotImplemented instead of TypeError
Charles R Harris
Sun Mar 13 17:17:23 CDT 2011
On Sun, Mar 13, 2011 at 3:53 PM, Hoyt Koepke <email@example.com>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
> > class is on the right or left. Sounds like you don't want to sublass
> > 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion