[Numpy-discussion] Empty strings not empty?

David Cournapeau cournape@gmail....
Tue Dec 29 18:18:27 CST 2009


On Wed, Dec 30, 2009 at 8:52 AM, Matthew Brett <matthew.brett@gmail.com> wrote:

> In [58]: e == z
> Out[58]: array([ True], dtype=bool)

Ok, it looks like there are at least two issues:
 - if an item in a string array is set to '¥x00', this seems to be
replace with '', but '' != '¥x00']

x = np.array(["¥x00"])
x[0] == '' " # True, but should be False ?

 - if an item in a string array is set to '', tostring will convert it
to '¥x00' :

x = np.array([""])
x.tostring() == ["¥00"] # True, but should be False ?

I guess the root cause is that there does not seem to be a "|S0" type
- but that may be difficult to implement, since the array would have >
0 items, but a 0 size. It may have other, but as quirky behavior.

What do you need this for ?

cheers,

David


More information about the NumPy-Discussion mailing list