[Numpy-svn] r3216 - trunk/numpy/oldnumeric

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Sep 25 12:52:04 CDT 2006


Author: oliphant
Date: 2006-09-25 12:51:52 -0500 (Mon, 25 Sep 2006)
New Revision: 3216

Modified:
   trunk/numpy/oldnumeric/typeconv.py
Log:
Add oldtypecodes to oldnumeric.typeconv so that old Numeric character codes can be identified.

Modified: trunk/numpy/oldnumeric/typeconv.py
===================================================================
--- trunk/numpy/oldnumeric/typeconv.py	2006-09-25 16:26:43 UTC (rev 3215)
+++ trunk/numpy/oldnumeric/typeconv.py	2006-09-25 17:51:52 UTC (rev 3216)
@@ -1,5 +1,5 @@
 
-__all__ = ['oldtype2dtype', 'convtypecode', 'convtypecode2']
+__all__ = ['oldtype2dtype', 'convtypecode', 'convtypecode2', 'oldtypecodes']
 
 import numpy as N
 
@@ -42,3 +42,20 @@
                 return N.dtype(typecode)
     else:
         return dtype
+
+_changedtypes = {'B': 'b',
+                 'b': '1',
+                 'h': 's',
+                 'H': 'w',
+                 'I': 'u'}
+                 
+class _oldtypecodes(dict):
+    def __getitem__(self, obj):
+        char = N.dtype(obj).char
+        try:
+            return _changedtypes[char]
+        except KeyError:
+            return char
+
+
+oldtypecodes = _oldtypecodes()



More information about the Numpy-svn mailing list