diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-09-25 17:51:52 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-09-25 17:51:52 +0000 |
commit | c7eb19932b673ffffcf49a55d52e005ec996cdda (patch) | |
tree | cd9360c896db76acedfb743127e63462c8cc8b46 /numpy/oldnumeric | |
parent | 25b594e5332f1f9bff3908f97bf45436b36a129b (diff) | |
download | numpy-c7eb19932b673ffffcf49a55d52e005ec996cdda.tar.gz |
Add oldtypecodes to oldnumeric.typeconv so that old Numeric character codes can be identified.
Diffstat (limited to 'numpy/oldnumeric')
-rw-r--r-- | numpy/oldnumeric/typeconv.py | 19 |
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() |