[Numpy-discussion] is this a chararray decode bug

josef.pktd@gmai... josef.pktd@gmai...
Wed Aug 12 11:07:37 CDT 2009


(copied from the lengthy unicode thread in scipy-dev, so it doesn't get lost)

this looks like a bug ? or is it a known limitation that chararrays
cannot be 0-d

>>> b0= np.array(u'\xe9','<U1').view(np.chararray)
>>> print b0.encode('cp1252')
Traceback (most recent call last):
 File "<pyshell#47>", line 1, in <module>
   print b0.encode('cp1252')
 File "C:\Programs\Python25\Lib\site-packages\numpy\core\defchararray.py",
line 217, in encode
   return self._generalmethod('encode', broadcast(self, encoding, errors))
 File "C:\Programs\Python25\Lib\site-packages\numpy\core\defchararray.py",
line 162, in _generalmethod
   newarr[:] = res
ValueError: cannot slice a 0-d array

Josef


More information about the NumPy-Discussion mailing list