[Numpy-discussion] Request for clarification from Travis

Charles R Harris charlesr.harris@gmail....
Tue Jun 24 22:12:35 CDT 2008

On Tue, Jun 24, 2008 at 8:40 PM, Travis E. Oliphant <oliphant@enthought.com>

> Charles R Harris wrote:
> >
> >
> > On Tue, Jun 24, 2008 at 1:41 PM, Travis E. Oliphant
> > <oliphant@enthought.com <mailto:oliphant@enthought.com>> wrote:
> >
> >
> >     > The problem is that numpy has a *bug*. I am trying to fix it and I
> >     > want your help figuring out how to do so while preserving the
> >     behavior
> >     > you had in mind. So if you could point out specific cases you were
> >     > thinking of it would help me with this.
> >     This is a hack to support matrices and other subclasses of ndarray
> >     like
> >     masked arrays.
> >
> >
> > That's what I was thinking. Do you have a test case? One that failed
> > without the NotImplemented return would be very helpful.
> There should be some in the test suite, but I'm not sure.  Perhaps the
> masked array test suite also has test cases.
> The NotImplemented is being returned so that the other operation will
> try and use it if it can.

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.

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.

I can't find __array_priority__ in your book, what exactly does it imply?


> -Travis
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080624/06917c99/attachment.html 

More information about the Numpy-discussion mailing list