summaryrefslogtreecommitdiff
path: root/numpy/lib/convertnumericA.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/convertnumericA.py')
-rw-r--r--numpy/lib/convertnumericA.py35
1 files changed, 33 insertions, 2 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')