NumPy types --> Numeric typecodes map?

Hi, Anybody know if there is a map between NumPy types and Numeric typecodes? Something like 'typecodes' for numarray:
numarray.typecode {'UInt64': 'U', 'Int32': 'i', 'Int16': 's', 'Float64': 'd', 'Object': 'O', 'UInt8': 'b', 'UInt32': 'u', 'Complex64': 'D', 'UInt16': 'w', 'Bool': 'B', 'Complex32': 'F', 'Int64': 'N', 'Int8': '1', 'Float32': 'f'}
Thanks, --
0,0< Francesc Altet http://www.carabos.com/ V V Cárabos Coop. V. Enjoy Data "-"

El dl 25 de 09 del 2006 a les 11:08 -0600, en/na Travis Oliphant va escriure:
Francesc Altet wrote:
Hi,
Anybody know if there is a map between NumPy types and Numeric typecodes? Something like 'typecodes' for numarray:
How about
dtype(obj).char?
This doesn't work for many types:
Numeric.array([1], typecode=numpy.dtype('int32').char) array([1])
this is fine, but:
Numeric.array([1], typecode=numpy.dtype('int16').char) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: typecode argument must be a valid type. Numeric.array([1], typecode=numpy.dtype('int64').char) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: typecode argument must be a valid type.
Anyway, this is not very important as I can do my own map internally. Thanks, --
0,0< Francesc Altet http://www.carabos.com/ V V Cárabos Coop. V. Enjoy Data "-"

Francesc Altet wrote:
El dl 25 de 09 del 2006 a les 11:08 -0600, en/na Travis Oliphant va escriure:
Francesc Altet wrote:
Hi,
Anybody know if there is a map between NumPy types and Numeric typecodes? Something like 'typecodes' for numarray:
Oh, you mean actual Numeric typecodes, not Numeric-like typecodes :-) dtype(obj).char will not work for the Numeric typecodes that changed, set up a dictionary-like object which uses dtype(obj).char on all but the ones that changed is my suggestion. See the core/numerictypes.py module for dictionary-like objects. Perhaps this would be a good thing to add to numpy/oldnumeric 'b' --> 'B' '1' --> 'b' 's' --> 'h' 'w' --> 'H' 'u' --> 'I' -Travis
participants (2)
-
Francesc Altet
-
Travis Oliphant