[SciPy-dev] 'nuther Q re: chararray

d_l_goldsmith@yaho... d_l_goldsmith@yaho...
Tue Aug 11 18:30:45 CDT 2009


>From "Guide to Numpy":

"Perhaps the easiest way to create a chararray is to use self.view(chararray) where self is an ndarray of string or unicode data-type."  

OK, but what is "(chararray)"?  In particular, my best guesses yielded:

>>> c = np.empty((2,2), dtype=unicode)
>>> c
array([[u'\u0f01\ude68', u'\uf880\udc00'],
       [u'\uf0c0\udc00', u'\u5300']],
      dtype='<U1')
>>> c.view(chararray) # can't mean it literally, right?
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'chararray' is not defined
>>> c.view(C) # does the expression assign a value to the argument?
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'C' is not defined
>>> C = np.chararray((2,2)) # this is most logical
>>> c.view(C)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Dtype must be a numpy data-type

So, what does Travis mean?  Thanks,

DG


      


More information about the Scipy-dev mailing list