PyObject typecodes are gone in numarray?
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 -- Dipl.-Ing. Berthold Höllmann __ Address: hoel@GL-Group.com G / \ L Germanischer Lloyd phone: +49-40-36149-7374 -+----+- Vorsetzen 32/35 P.O.Box 111606 fax : +49-40-36149-7320 \__/ D-20459 Hamburg D-20416 Hamburg **************************************************** Beachten Sie: Wir moechten Sie informieren, dass die E-Mail-Adresse des Germanischen Lloyd sowie unsere Web-Adresse mit Wirkung vom 1. Maerz 2003 auf den Namen gl-group.com umgestellt wurde. Dies bedeutet, dass die bisherige Adresse Kurzzeichen@germanlloyd.org durch die neue Adresse Kurzzeichen@gl-group.com ersetzt wird. Die Homepage des GL ist kuenftig ueber die Adresse 'http://www.gl-group.com' aufrufbar. Die bisher verwendeten Adressen bleiben für eine Uebergangsfrist erreichbar. **************************************************** Please notice: We would like to inform you that the e-mail address of Germanischer Lloyd as well as our internet address had been changed to gl-group.com with effect from 1st March 2003. This means that the previous address shortmark@germanlloyd.org will be replaced by shortmark@gl-group.com. From now on the GL homepage can be accessed at the address 'http://www.gl-group.com'. The old addresses remain valid for a transitional period. **************************************************** This e-mail contains confidential information for the exclusive attention of the intended addressee. Any access of third parties to this e-mail is unauthorised. Any use of this e-mail by unintended recipients such as copying, distribution, disclosure etc. is prohibited and may be unlawful. When addressed to our clients the content of this e-mail is subject to the General Terms and Conditions of GL's Group of Companies applicable at the date of this e-mail. GL's Group of Companies does not warrant and/or guarantee that this message at the moment of receipt is authentic, correct and its communication free of errors, interruption etc.
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
I wrote:
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).
Having looked at it in more detail, it is more involved that I had hoped so it won't be done in an afternoon, but it doesn't look difficult. I think we will have to wait until we finish our current round of optimization work before adding this capability. While the PyObject type can use much of NDArray, it does require some new machinery to handle safety issues regarding Python objects (ensuring that the buffer used for such arrays always contain valid PyObject entries and nothing but, plus handling inref'ing and decref'ing all entries in arrays as appropriate). Perry
participants (2)
-
Berthold Höllmann
-
Perry Greenfield