summaryrefslogtreecommitdiff
path: root/numpy/oldnumeric
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/oldnumeric')
-rw-r--r--numpy/oldnumeric/typeconv.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/numpy/oldnumeric/typeconv.py b/numpy/oldnumeric/typeconv.py
index 9e82b2619..cb7239027 100644
--- a/numpy/oldnumeric/typeconv.py
+++ b/numpy/oldnumeric/typeconv.py
@@ -1,5 +1,5 @@
-__all__ = ['oldtype2dtype', 'convtypecode', 'convtypecode2']
+__all__ = ['oldtype2dtype', 'convtypecode', 'convtypecode2', 'oldtypecodes']
import numpy as N
@@ -42,3 +42,20 @@ def convtypecode2(typecode, dtype=None):
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()