[Numpy-discussion] Empty strings not empty?

David Cournapeau cournape at gmail.com
Tue Dec 29 19:18:27 EST 2009


On Wed, Dec 30, 2009 at 8:52 AM, Matthew Brett <matthew.brett at 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