[Numpy-svn] r2967 - trunk/numpy/lib

numpy-svn at scipy.org numpy-svn at scipy.org
Sat Aug 5 03:59:45 CDT 2006


Author: oliphant
Date: 2006-08-05 03:59:42 -0500 (Sat, 05 Aug 2006)
New Revision: 2967

Modified:
   trunk/numpy/lib/convertnumericA.py
   trunk/numpy/lib/convertnumericB.py
Log:
Fix convertnumericA.py to fix transition from 'b' to 'B'

Modified: trunk/numpy/lib/convertnumericA.py
===================================================================
--- trunk/numpy/lib/convertnumericA.py	2006-08-05 08:05:11 UTC (rev 2966)
+++ trunk/numpy/lib/convertnumericA.py	2006-08-05 08:59:42 UTC (rev 2967)
@@ -15,7 +15,13 @@
  * 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 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 @@
 
 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')

Modified: trunk/numpy/lib/convertnumericB.py
===================================================================
--- trunk/numpy/lib/convertnumericB.py	2006-08-05 08:05:11 UTC (rev 2966)
+++ trunk/numpy/lib/convertnumericB.py	2006-08-05 08:59:42 UTC (rev 2967)
@@ -3,20 +3,26 @@
 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 oldnumeric.linear_algebra,
+   oldnumeric.random_array, and oldnumeric.fft
 
- * converts old function names in linalg.old, random.old, dft.old
-
 """
-__all__ = ['fromfile', 'fromstr']
+#__all__ = ['fromfile', 'fromstr']
+__all__ = []
 
+import warnings
+warnings.warn("convetnumericB is not finished yet.")
+
 import sys
 import os
 import re



More information about the Numpy-svn mailing list