[Numpy-discussion] rank-0 chararrays?

Francesc Alted falted at openlc.org
Mon Feb 17 11:08:01 CST 2003


Hi,

I'm trying to map Numeric character typecode ('c') to chararrays, but I have
a problem to distinguish between

In [109]: chararray.array("qqqq")
Out[109]: CharArray(['qqqq'])

and

In [110]: chararray.array(["qqqq"])  # Note the extra "[" "]"
Out[110]: CharArray(['qqqq'])   # The same result as 109

while in Numeric we have:

In [113]: Numeric.array("qqqq")
Out[113]: array([q, q, q, q],'c')

In [114]: Numeric.array(["qqqq"])
Out[114]: array([       [q, q, q, q]],'c')  # Differs from 113

even in numarray objects, rank-0 seems to work well:

In [107]: numarray.array(1)
Out[107]: array(1)

In [108]: numarray.array([1])
Out[108]: array([1])   # Objects differ


So, it seems like if chararray does not support well rank-0 objects. Is this
the expected behavior?. If yes, we have no possibility to distinguish
between object 109 and 110, and I'd like to distinguish between this two.
What can be done to achieve this?

Thanks,

-- 
Francesc Alted




More information about the Numpy-discussion mailing list