[Numpy-discussion] str == int puzzlement

Matthew Brett matthew.brett@gmail....
Sat Jul 31 17:24:29 CDT 2010


Hi,

> Yeah, it's just that numpy knows that it cannot compare pears with apples:
>
>>>> a = numpy.asarray(['a', 'b'])
>>>> a.__eq__(1)
> NotImplemented

Thank you - that's very helpful and clear.

> Maybe it would be better to raise a ValueError, which is not caught by
> the evaluation mechanism, to prevent such stuff.

Sorry that this is not yet clear to me, but, is it true then that:

The only situation where array.__eq__ sensibly falls back to python
__eq__ is for the individual elements of object arrays?

Thanks again,

Matthew


More information about the NumPy-Discussion mailing list