/usr/lib64/python2.6/site-packages/numpy/oldnumeric
NameSizeModeActions
tests/-0755rm
alter_code1.py84980644editdlrm
alter_code1.pyc97610644editdlrm
alter_code1.pyo97610644editdlrm
alter_code2.py46350644editdlrm
alter_code2.pyc61180644editdlrm
alter_code2.pyo61180644editdlrm
arrayfns.py25320644editdlrm
arrayfns.pyc44310644editdlrm
arrayfns.pyo44310644editdlrm
array_printer.py4560644editdlrm
array_printer.pyc6690644editdlrm
array_printer.pyo6690644editdlrm
compat.py28370644editdlrm
compat.pyc45580644editdlrm
compat.pyo45580644editdlrm
fft.py8690644editdlrm
fft.pyc10510644editdlrm
fft.pyo10510644editdlrm
fix_default_axis.py80350644editdlrm
fix_default_axis.pyc79790644editdlrm
fix_default_axis.pyo79790644editdlrm
functions.py36400644editdlrm
functions.pyc74800644editdlrm
functions.pyo74800644editdlrm
linear_algebra.py21800644editdlrm
linear_algebra.pyc34230644editdlrm
linear_algebra.pyo34230644editdlrm
ma.py756760644editdlrm
ma.pyc862410644editdlrm
ma.pyo862410644editdlrm
matrix.py16040644editdlrm
matrix.pyc23810644editdlrm
matrix.pyo23810644editdlrm
misc.py10450644editdlrm
misc.pyc14180644editdlrm
misc.pyo14180644editdlrm
mlab.py34580644editdlrm
mlab.pyc54650644editdlrm
mlab.pyo54650644editdlrm
precision.py42390644editdlrm
precision.pyc39930644editdlrm
precision.pyo39930644editdlrm
random_array.py114540644editdlrm
random_array.pyc142820644editdlrm
random_array.pyo142820644editdlrm
rng.py37540644editdlrm
rng.pyc69260644editdlrm
rng.pyo69260644editdlrm
rng_stats.py13410644editdlrm
rng_stats.pyc18810644editdlrm
rng_stats.pyo18810644editdlrm
setup.py3350644editdlrm
setup.pyc6660644editdlrm
setup.pyo6660644editdlrm
setupscons.py2820644editdlrm
setupscons.pyc6150644editdlrm
setupscons.pyo6150644editdlrm
typeconv.py16220644editdlrm
typeconv.pyc16350644editdlrm
typeconv.pyo16350644editdlrm
ufuncs.py12310644editdlrm
ufuncs.pyc18300644editdlrm
ufuncs.pyo18300644editdlrm
user_array.py1820644editdlrm
user_array.pyc3700644editdlrm
user_array.pyo3700644editdlrm
__init__.py8270644editdlrm
__init__.pyc10260644editdlrm
__init__.pyo10260644editdlrm
Edit: /usr/lib64/python2.6/site-packages/numpy/oldnumeric/fix_default_axis.py (8035B)
""" This module adds the default axis argument to code which did not specify it for the functions where the default was changed in NumPy. The functions changed are add -1 ( all second argument) ====== nansum nanmax nanmin nanargmax nanargmin argmax argmin compress 3 add 0 ====== take 3 repeat 3 sum # might cause problems with builtin. product sometrue alltrue cumsum cumproduct average ptp cumprod prod std mean """ __all__ = ['convertfile', 'convertall', 'converttree'] import sys import os import re import glob _args3 = ['compress', 'take', 'repeat'] _funcm1 = ['nansum', 'nanmax', 'nanmin', 'nanargmax', 'nanargmin', 'argmax', 'argmin', 'compress'] _func0 = ['take', 'repeat', 'sum', 'product', 'sometrue', 'alltrue', 'cumsum', 'cumproduct', 'average', 'ptp', 'cumprod', 'prod', 'std', 'mean'] _all = _func0 + _funcm1 func_re = {} for name in _all: _astr = r"""%s\s*[(]"""%name func_re[name] = re.compile(_astr) import string disallowed = '_' + string.uppercase + string.lowercase + string.digits def _add_axis(fstr, name, repl): alter = 0 if name in _args3: allowed_comma = 1 else: allowed_comma = 0 newcode = "" last = 0 for obj in func_re[name].finditer(fstr): nochange = 0 start, end = obj.span() if fstr[start-1] in disallowed: continue if fstr[start-1] == '.' \ and fstr[start-6:start-1] != 'numpy' \ and fstr[start-2:start-1] != 'N' \ and fstr[start-9:start-1] != 'numarray' \ and fstr[start-8:start-1] != 'numerix' \ and fstr[start-8:start-1] != 'Numeric': continue if fstr[start-1] in ['\t',' ']: k = start-2 while fstr[k] in ['\t',' ']: k -= 1 if fstr[k-2:k+1] == 'def' or \ fstr[k-4:k+1] == 'class': continue k = end stack = 1 ncommas = 0 N = len(fstr) while stack: if k>=N: nochange =1 break if fstr[k] == ')': stack -= 1 elif fstr[k] == '(': stack += 1 elif stack == 1 and fstr[k] == ',': ncommas += 1 if ncommas > allowed_comma: nochange = 1 break k += 1 if nochange: continue alter += 1 newcode = "%s%s,%s)" % (newcode, fstr[last:k-1], repl) last = k if not alter: newcode = fstr else: newcode = "%s%s" % (newcode, fstr[last:]) return newcode, alter def _import_change(fstr, names): # Four possibilities # 1.) import numpy with subsequent use of numpy. # change this to import numpy.oldnumeric as numpy # 2.) import numpy as XXXX with subsequent use of # XXXX. ==> import numpy.oldnumeric as XXXX # 3.) from numpy import * # with subsequent use of one of the names # 4.) from numpy import ..., , ... (could span multiple # lines. ==> remove all names from list and # add from numpy.oldnumeric import num = 0 # case 1 importstr = "import numpy" ind = fstr.find(importstr) if (ind > 0): found = 0 for name in names: ind2 = fstr.find("numpy.%s" % name, ind) if (ind2 > 0): found = 1 break if found: fstr = "%s%s%s" % (fstr[:ind], "import numpy.oldnumeric as numpy", fstr[ind+len(importstr):]) num += 1 # case 2 importre = re.compile("""import numpy as ([A-Za-z0-9_]+)""") modules = importre.findall(fstr) if len(modules) > 0: for module in modules: found = 0 for name in names: ind2 = fstr.find("%s.%s" % (module, name)) if (ind2 > 0): found = 1 break if found: importstr = "import numpy as %s" % module ind = fstr.find(importstr) fstr = "%s%s%s" % (fstr[:ind], "import numpy.oldnumeric as %s" % module, fstr[ind+len(importstr):]) num += 1 # case 3 importstr = "from numpy import *" ind = fstr.find(importstr) if (ind > 0): found = 0 for name in names: ind2 = fstr.find(name, ind) if (ind2 > 0) and fstr[ind2-1] not in disallowed: found = 1 break if found: fstr = "%s%s%s" % (fstr[:ind], "from numpy.oldnumeric import *", fstr[ind+len(importstr):]) num += 1 # case 4 ind = 0 importstr = "from numpy import" N = len(importstr) while 1: ind = fstr.find(importstr, ind) if (ind < 0): break ind += N ptr = ind+1 stack = 1 while stack: if fstr[ptr] == '\\': stack += 1 elif fstr[ptr] == '\n': stack -= 1 ptr += 1 substr = fstr[ind:ptr] found = 0 substr = substr.replace('\n',' ') substr = substr.replace('\\','') importnames = [x.strip() for x in substr.split(',')] # determine if any of names are in importnames addnames = [] for name in names: if name in importnames: importnames.remove(name) addnames.append(name) if len(addnames) > 0: fstr = "%s%s\n%s\n%s" % \ (fstr[:ind], "from numpy import %s" % \ ", ".join(importnames), "from numpy.oldnumeric import %s" % \ ", ".join(addnames), fstr[ptr:]) num += 1 return fstr, num def add_axis(fstr, import_change=False): total = 0 if not import_change: for name in _funcm1: fstr, num = _add_axis(fstr, name, 'axis=-1') total += num for name in _func0: fstr, num = _add_axis(fstr, name, 'axis=0') total += num return fstr, total else: fstr, num = _import_change(fstr, _funcm1+_func0) return fstr, num def makenewfile(name, filestr): fid = file(name, 'w') fid.write(filestr) fid.close() def getfile(name): fid = file(name) filestr = fid.read() fid.close() return filestr def copyfile(name, fstr): base, ext = os.path.splitext(name) makenewfile(base+'.orig', fstr) return def convertfile(filename, import_change=False): """Convert the filename given from using Numeric to using NumPy Copies the file to filename.orig and then over-writes the file with the updated code """ filestr = getfile(filename) newstr, total = add_axis(filestr, import_change) if total > 0: print "Changing ", filename copyfile(filename, filestr) makenewfile(filename, newstr) sys.stdout.flush() def fromargs(args): filename = args[1] convertfile(filename) def convertall(direc=os.path.curdir, import_change=False): """Convert all .py files in the directory given For each file, a backup of .py is made as .py.orig. A new file named .py is then written with the updated code. """ files = glob.glob(os.path.join(direc,'*.py')) for afile in files: convertfile(afile, import_change) def _func(arg, dirname, fnames): convertall(dirname, import_change=arg) def converttree(direc=os.path.curdir, import_change=False): """Convert all .py files in the tree given """ os.path.walk(direc, _func, import_change) if __name__ == '__main__': fromargs(sys.argv)