[Numpy-discussion] Request for clarification from Travis

Charles R Harris charlesr.harris@gmail....
Tue Jun 24 13:06:47 CDT 2008

Hi Travis,

Could you expand on your thinking  concerning NotImplemented? The relevant
code is:

     * FAIL with NotImplemented if the other object has
     * the __r<op>__ method and has __array_priority__ as
     * an attribute (signalling it can handle ndarray's)
     * and is not already an ndarray
    if ((arg_types[1] == PyArray_OBJECT) &&                         \
        (loop->ufunc->nin==2) && (loop->ufunc->nout == 1)) {
        PyObject *_obj = PyTuple_GET_ITEM(args, 1);
        if (!PyArray_CheckExact(_obj) &&                        \
            PyObject_HasAttrString(_obj, "__array_priority__") && \
            _has_reflected_op(_obj, loop->ufunc->name)) {
            loop->notimplemented = 1;
            return nargs;

And the check is made after the needed promotions have been determined and
stored in arg_types. Consequently if a type is promoted to an object array,
as happens for the shift operations with floating scalars, the rest of the
conditions will be checked and pass because numpy scalar types aren't
arrays. I wonder if that is what you intended here? The reason I ask is that
this determination should be associated with the standard slot functions
when the call is made and I don't want to worry about type promotions.
Further, I wonder why you want this return before the attempt to run the
function with the current arguments is made. So it would be very helpful if
you could clarify what you aim to achieve here.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080624/f676f4e3/attachment.html 

More information about the Numpy-discussion mailing list