[Numpy-discussion] NotImplemented returns

Charles R Harris charlesr.harris at gmail.com
Thu May 27 14:34:08 EDT 2010


On Thu, May 27, 2010 at 9:59 AM, <josef.pktd at gmail.com> wrote:

> A while ago we had a brief discussion about this.
>
>
> Is this a feature? or should there be a ticket for this
>
> >>> np.sqrt('5')
> NotImplemented
> >>> a = np.sqrt('5')
> >>> a
> NotImplemented
> >>> type(a)
> <type 'NotImplementedType'>
>
>
What numpy version? I get

In [2]: sqrt(['a'])
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)

/home/charris/<ipython console> in <module>()

NotImplementedError: Not implemented for this type

In [3]: sqrt('a')
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)

/home/charris/<ipython console> in <module>()

NotImplementedError: Not implemented for this type


Which is entirely different. Note that Py_NotImplemented is *not* only for
comparisons, it is a signal to the interpreter to try the r* version of a
binary operator.


OTOH,

In [4]: maximum('a',1)
Out[4]: NotImplemented

Which is still a problem. I think no ufunc should return NotImplemented, it
should be reserved to methods so the interpreter will handle it correctly.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100527/3aec452a/attachment.html>


More information about the NumPy-Discussion mailing list