diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/lib/convertnumericA.py | 35 | ||||
-rw-r--r-- | numpy/lib/convertnumericB.py | 16 |
2 files changed, 44 insertions, 7 deletions
diff --git a/numpy/lib/convertnumericA.py b/numpy/lib/convertnumericA.py index c3748bae3..72cc33acb 100644 --- a/numpy/lib/convertnumericA.py +++ b/numpy/lib/convertnumericA.py @@ -15,7 +15,13 @@ Makes the following changes: * Convert xx.savespace(?) to pass + ## xx.savespace(?) * Converts uses of 'b' to 'B' in the typecode-position of - functions and methods + functions: + eye, tri (in position 4) + ones, zeros, identity, empty, array, asarray, arange, + fromstring, indices, array_constructor (in position 2) + + and methods: + astype --- only argument """ __all__ = ['fromfile', 'fromstr'] @@ -24,6 +30,31 @@ import os import re import glob + +_func4 = ['eye', 'tri'] +_meth1 = ['astype'] +_func2 = ['ones', 'zeros', 'identity', 'fromstring', 'indices', + 'empty', 'array', 'asarray', 'arange', 'array_constructor'] + +func_re = {} + +for name in _func2: + _astr = r"""(%s\s*[(][^,]*?[,][^'"]*?['"])b(['"][^)]*?[)])"""%name + func_re[name] = re.compile(_astr, re.DOTALL) + +for name in _func4: + _astr = r"""(%s\s*[(][^,]*?[,][^,]*?[,][^,]*?[,][^'"]*?['"])b(['"][^)]*?[)])"""%name + func_re[name] = re.compile(_astr, re.DOTALL) + +for name in _meth1: + _astr = r"""(.%s\s*[(][^'"]*?['"])b(['"][^)]*?[)])"""%name + func_re[name] = re.compile(_astr, re.DOTALL) + +def fixtypechars(fstr): + for name in _func2 + _func4 + _meth1: + fstr = func2_re[name].sub('\\1B\\2',fstr) + return fstr + flatindex_re = re.compile('([.]flat(\s*?[[=]))') def changeimports(fstr, name, newname): @@ -74,7 +105,7 @@ def replaceother(astr): import datetime def fromstr(filestr): - #filestr = replacetypechars(filestr) + filestr = fixtypechars(filestr) filestr, fromall1 = changeimports(filestr, 'Numeric', 'numpy.oldnumeric') filestr, fromall1 = changeimports(filestr, 'multiarray','numpy.oldnumeric') filestr, fromall1 = changeimports(filestr, 'umath', 'numpy.oldnumeric') diff --git a/numpy/lib/convertnumericB.py b/numpy/lib/convertnumericB.py index 36bdd8572..c1c8ae072 100644 --- a/numpy/lib/convertnumericB.py +++ b/numpy/lib/convertnumericB.py @@ -3,19 +3,25 @@ This module converts code written for numpy.oldnumeric to work with numpy Makes the following changes: - * Converts typecharacters + * Converts typecharacters '1swu' to 'bhHI' respectively + when used as typecodes * Changes import statements * Change typecode= to dtype= - * Eliminates savespace=xxx + * Eliminates savespace=xxx keyword arguments + * Removes it when keyword is not given as well * replaces matrixmultiply with dot * converts functions that don't give axis= keyword that have changed * converts functions that don't give typecode= keyword that have changed * converts use of capitalized type-names - - * converts old function names in linalg.old, random.old, dft.old + * converts old function names in oldnumeric.linear_algebra, + oldnumeric.random_array, and oldnumeric.fft """ -__all__ = ['fromfile', 'fromstr'] +#__all__ = ['fromfile', 'fromstr'] +__all__ = [] + +import warnings +warnings.warn("convetnumericB is not finished yet.") import sys import os |