[Numpy-discussion] ndarray special methods should raise NotImplemented instead of TypeError
Charles R Harris
charlesr.harris at gmail.com
Sun Mar 13 18:17:23 EDT 2011
On Sun, Mar 13, 2011 at 3:53 PM, Hoyt Koepke <hoytak at 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
> > 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