[Numpy-discussion] NotImplemented returns

josef.pktd at gmail.com josef.pktd at gmail.com
Thu May 27 14:40:07 EDT 2010


On Thu, May 27, 2010 at 2:34 PM, Charles R Harris
<charlesr.harris at gmail.com> wrote:
>
>
> 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

Obviously I'm too old (numpy 1.4.0)

Josef

>
> 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
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>



More information about the NumPy-Discussion mailing list