[Numpy-discussion] np.equal

Michael Droettboom mdroe at stsci.edu
Mon Dec 7 09:06:00 EST 2009


There was some discussion on this recently.  "==" actually has special 
fall-back code for strings, whereas "equal" is just a "raw" ufunc, and 
no ufunc's support strings.

http://www.mail-archive.com/numpy-discussion@scipy.org/msg21408.html

Of course bool(NotImplemented) == True is sort of a separate issue that 
can be dealt with independently of whether ufuncs grow string support of 
not.

Mike

Pauli Virtanen wrote:
> su, 2009-12-06 kello 23:01 -0800, Fernando Perez kirjoitti:
>   
>> 2009/12/6 josef.pktd <josef.pktd at gmail.com>:
>>     
>>>>>> np.equal(np.arange(5),'a')
>>>>>>             
>>> NotImplemented
>>>       
>> Why is NotImplemented a *return* value?  Normally NotImplementedError
>> is a raised exception, but if it's not implemented, it shouldn't be
>> returned as a value.
>>     
>
> Maybe it is so because some code paths are shared with the == operation?
>
> But in any case, NotImplemented should never be returned to the user --
> I believe it's only meant to be an internal value used in determining
> the proper comparison operation between values.
>
> A bug ticket should be filed for this, I believe.
>
>   

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA




More information about the NumPy-Discussion mailing list