numpy.oldnumeric.alter_code1
index
/usr/lib/python2.6/dist-packages/numpy/oldnumeric/alter_code1.py

This module converts code written for Numeric to run with numpy
 
Makes the following changes:
 * Changes import statements (warns of use of from Numeric import *)
 * Changes import statements (using numerix) ...
 * Makes search and replace changes to:
   - .typecode()
   - .iscontiguous()
   - .byteswapped()
   - .itemsize()
   - .toscalar()
 * Converts .flat to .ravel() except for .flat = xxx or .flat[xxx]
 * Replace xxx.spacesaver() with True
 * Convert xx.savespace(?) to pass + ## xx.savespace(?)
 
 * Converts uses of 'b' to 'B' in the typecode-position of
   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
    -- converts uses of '1', 's', 'w', and 'u' to
    -- 'b', 'h', 'H', and 'I'
 
 * Converts uses of type(...) is <type>
   isinstance(..., <type>)

 
Modules
       
datetime
glob
os
re
sys

 
Functions
       
_func(arg, dirname, fnames)
changeimports(fstr, name, newname)
convertall(direc='.', orig=1)
Convert all .py files to use numpy.oldnumeric (from Numeric) in the directory given
 
For each changed file, a backup of <usesnumeric>.py is made as
<usesnumeric>.py.orig.  A new file named <usesnumeric>.py
is then written with the updated code.
convertfile(filename, orig=1)
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
convertsrc(direc='.', ext=None, orig=1)
Replace Numeric/arrayobject.h with numpy/oldnumeric.h in all files in the
directory with extension give by list ext (if ext is None, then all files are
replaced).
converttree(direc='.')
Convert all .py files and source code files in the tree given
fixistesting(astr)
fixtypechars(fstr)
fromargs(args)
fromstr(filestr)
makenewfile(name, filestr)
replaceattr(astr)
replaceother(astr)
#shpe = re.compile(r'(\S+\s*)[.]shape\s*=[^=]\s*(.+)')

 
Data
        __all__ = ['convertfile', 'convertall', 'converttree', 'convertsrc']
__file__ = '/usr/lib/python2.6/dist-packages/numpy/oldnumeric/alter_code1.pyc'
__name__ = 'numpy.oldnumeric.alter_code1'
__package__ = 'numpy.oldnumeric'
_astr = r'type\s*[(]([^)]*)[)]\s+(?:is|==)\s+(.*?ComplexType)'
_chars = {'1': 'b', 's': 'h', 'u': 'I', 'w': 'H'}
_func2 = ['ones', 'zeros', 'identity', 'fromstring', 'indices', 'empty', 'array', 'asarray', 'arange', 'array_constructor']
_func4 = ['eye', 'tri']
_meth1 = ['astype']
_types = ['float', 'int', 'complex', 'ArrayType', 'FloatType', 'IntType', 'ComplexType']
char = 'w'
flatindex_re = <_sre.SRE_Pattern object at 0x7126260>
func_re = {'arange': <_sre.SRE_Pattern object at 0x7182e70>, 'array': <_sre.SRE_Pattern object at 0x7054160>, 'array_constructor': <_sre.SRE_Pattern object at 0x7182ba0>, 'asarray': <_sre.SRE_Pattern object at 0x71829d0>, 'astype': <_sre.SRE_Pattern object at 0x7183970>, 'empty': <_sre.SRE_Pattern object at 0x7054430>, 'eye': <_sre.SRE_Pattern object at 0x71834b0>, 'fromstring': <_sre.SRE_Pattern object at 0x709cc60>, 'identity': <_sre.SRE_Pattern object at 0x7181360>, 'indices': <_sre.SRE_Pattern object at 0x70ba2f0>, ...}
header_re = <_sre.SRE_Pattern object at 0x7197b80>
istest_re = {'ArrayType': <_sre.SRE_Pattern object at 0x7195a50>, 'ComplexType': <_sre.SRE_Pattern object at 0x7197760>, 'FloatType': <_sre.SRE_Pattern object at 0x71963f0>, 'IntType': <_sre.SRE_Pattern object at 0x7196100>, 'complex': <_sre.SRE_Pattern object at 0x7195ca0>, 'float': <_sre.SRE_Pattern object at 0x7195600>, 'int': <_sre.SRE_Pattern object at 0x71953b0>}
meth_re = {'1': <_sre.SRE_Pattern object at 0x7183b10>, 's': <_sre.SRE_Pattern object at 0x7183cb0>, 'u': <_sre.SRE_Pattern object at 0x71837c0>, 'w': <_sre.SRE_Pattern object at 0x7193c60>}
name = 'ComplexType'
svspc2 = <_sre.SRE_Pattern object at 0x7197530>
svspc3 = <_sre.SRE_Pattern object at 0x7197350>