[Numpy-discussion] np.equal

josef.pktd@gmai... josef.pktd@gmai...
Sun Dec 6 06:57:59 CST 2009


what's the difference in the implementation between np.equal and == ?
np.equal raises NotImplemented for strings, while == works.

>>> aa
array(['a', 'b', 'a', 'aa', 'a'],
      dtype='|S2')

>>> aa == 'a'
array([ True, False,  True, False,  True], dtype=bool)
>>> np.equal(aa,'a')
NotImplemented


>>> np.equal(np.arange(5),1)
array([False,  True, False, False, False], dtype=bool)
>>> np.equal(np.arange(5),'a')
NotImplemented
>>> np.arange(5) == 'a'
False

Josef


More information about the NumPy-Discussion mailing list