[Numpy-discussion] numpy / numarray chararray incompatibility

Christopher Hanley chanley at stsci.edu
Wed Jan 18 10:47:06 EST 2006


Hi Travis,

The following works in numarray but fails in numpy:


In [23]: a1 = numarray.strings.array(['abc','def','xx'])

In [24]: a1
Out[24]: CharArray(['abc', 'def', 'xx'])

In [25]: from numpy.core import char

In [26]: a = char.array(['abc', 'def', 'xx'])
---------------------------------------------------------------------------
exceptions.TypeError                                 Traceback (most 
recent call last)

/data/sparty1/dev/pyfits-numpy/test/<console>

/data/sparty1/dev/site-packages/lib/python/numpy/core/defchararray.py in 
array(obj, itemsize, copy, unicode, fortran)
     321         dtype += str(itemsize)
     322
--> 323     if isinstance(obj, str) or isinstance(obj, unicode):
     324         if itemsize is None:
     325             itemsize = len(obj)

TypeError: isinstance() arg 2 must be a class, type, or tuple of classes 
and types

Chris





More information about the NumPy-Discussion mailing list