[Numpy-discussion] Padding policy in CharArrays

Francesc Altet faltet at carabos.com
Sat Jan 1 14:01:13 EST 2005


Hi,

I'm experiencing some problems derived from the fact that CharArrays in
numarray are padded with spaces. That leads to somewhat curious consequences
like this:

In [180]: a=strings.array(None, itemsize = 4, shape=1)    
In [181]: a[0] = '0'
In [182]: a >= '0\x00\x00\x00\x01'
Out[182]: array([1], type=Bool)  # Incorrect

but...

In [183]: a[0] >= '0\x00\x00\x00\x01'
Out[183]: False  # correct

While this is not a bug (see the padding policy for chararrays) I think it
would be much better to use '\0x00' as default padding. Would be any problem
with that?. If yes, well, I've found a workaround on this, but quite
inelegant I'm afraid :-/

Have a Happy New Year!

-- 
Francesc Altet     >qo<   http://www.carabos.com/
Cárabos Coop. V.   V  V   Enjoy Data
                    ""






More information about the NumPy-Discussion mailing list