[Numpy-discussion] stringscalar comparisons with a chararray

Michael Sorich michael.sorich at gmail.com
Tue Mar 28 22:47:04 CST 2006

As shown in the example below, chararray comparisons do not seem to work
well when stringscalars are used. In the example below I am also curious as
to whether the the length of  c[0] should be 2 instead of 5.

 numpy.__version__ 0.9.6
>>> from numpy import *
>>> c =char.array(['on','two','three'])
>>> c
chararray([on, two, three],
>>> c=='on'
array([True, False, False], dtype=bool)
>>> c==c[0]
array([False, False, False], dtype=bool)
>>> c==str(c[0])
array([True, False, False], dtype=bool)
>>> c[0]
>>> len(c[0])
>>> c.dtype
>>> c==c[2]
array([False, False, True], dtype=bool)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060328/40d678ea/attachment-0001.html 

More information about the Numpy-discussion mailing list