[Numpy-discussion] __eq__ with str and object

Michael Droettboom mdroe at stsci.edu
Tue May 25 16:21:20 EDT 2010


Seems like a bug to me.  Certain branches in _array_richcompare return 
False to fail rather than Py_NotImplemented, which means the 
string-understanding comparison fallbacks don't run.  Attached is a 
(simple) patch that resolves this bug, and doesn't seem to cause any of 
the unit tests to fail.  Does this make sense to someone with a better 
understanding of the rich comparison code than I?

Mike

On 05/25/2010 12:54 PM, Keith Goodman wrote:
>>> a1 = np.array(['a', 'b'], dtype=object)
>>> >>  a2 = np.array(['a', 'b'])
>>> >>
>>> >>  a1 == a2
>>>        
>     array([ True,  True], dtype=bool)  # Looks good
>    
>>> >>  a2 == a1
>>>        
>     False  # Should I have expected this?
>
>    


-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

-------------- next part --------------
A non-text attachment was scrubbed...
Name: char_eq.diff
Type: text/x-patch
Size: 2049 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100525/2a5848f0/attachment.bin>


More information about the NumPy-Discussion mailing list