[Numpy-discussion] PyObject typecodes are gone in numarray?

Perry Greenfield perry at stsci.edu
Wed Mar 19 08:17:09 CST 2003


> 
> Hello,
> 
> I am trying to convert a larger project of ours from Numeric to
> numarray under some time pressure. One stumbling point is that
> numarray does not support the Numeric "PyObject" typecode for
> arrays. I am mapping some kind or database structure to Numeric arrays
> and am using PyObject arrays for storing String columns for
> consistency with the numeric columns. How would this be solved with
> numarray? Example:
> 
> >python
> Python 2.2.1 (#1, Dec 13 2002, 10:37:32) 
> [GCC 3.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import Numeric as N
> >>> a=N.zeros(3, N.PyObject)
> >>> a[:] = ['abc', 'def', 'ghi']
> >>> a
> array([abc , def , ghi ],'O')
> 
> Thanks
> Berthold
> -- 

At the moment, numarray doesn't support PyObject arrays (though 
I believe that adding such capability is simple enough I am
tempted to try to do so today!).

Another possibility is to use chararray *if* you are dealing with
fixed length strings. We use that as a way of providing character
fields to our record array class (recarray). If this is so, you may
find that more useful. Let us know and we will point you to where
you can find more information (recarray and chararray aren't that
well documented right now).

Perry




More information about the Numpy-discussion mailing list