summaryrefslogtreecommitdiff
path: root/numpy/numarray
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-08-18 11:51:25 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-08-18 11:51:25 -0600
commitfbd6510d58a47ea0d166c48a82793f05425406e4 (patch)
tree330ce703eb02d20f96099c3fe0fc36ae33d4905b /numpy/numarray
parent8ddb0ce0acafe75d78df528b4d2540dfbf4b364d (diff)
downloadnumpy-fbd6510d58a47ea0d166c48a82793f05425406e4.tar.gz
STY: Giant comma spacing fixup.
Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long and will need to be broken at some point. OTOH, some lines were already too long and need to be broken at some point. Now seems as good a time as any to do this with open PRs at a minimum.
Diffstat (limited to 'numpy/numarray')
-rw-r--r--numpy/numarray/alter_code1.py36
-rw-r--r--numpy/numarray/alter_code2.py2
-rw-r--r--numpy/numarray/functions.py22
-rw-r--r--numpy/numarray/numerictypes.py54
-rw-r--r--numpy/numarray/session.py16
-rw-r--r--numpy/numarray/setup.py2
6 files changed, 66 insertions, 66 deletions
diff --git a/numpy/numarray/alter_code1.py b/numpy/numarray/alter_code1.py
index a80a5ae3c..ff50d7c50 100644
--- a/numpy/numarray/alter_code1.py
+++ b/numpy/numarray/alter_code1.py
@@ -69,12 +69,12 @@ def changeimports(fstr, name, newname):
name_ = name
if ('.' in name):
- name_ = name.replace('.','_')
+ name_ = name.replace('.', '_')
fstr = re.sub(r'(import\s+[^,\n\r]+,\s*)(%s)' % name,
"\\1%s as %s" % (newname, name), fstr)
fstr = fstr.replace(importasstr, 'import %s as ' % newname)
- fstr = fstr.replace(importstr, 'import %s as %s' % (newname,name_))
+ fstr = fstr.replace(importstr, 'import %s as %s' % (newname, name_))
if (name_ != name):
fstr = fstr.replace(name, name_)
@@ -82,7 +82,7 @@ def changeimports(fstr, name, newname):
Nlen = len(fromstr)
Nlen2 = len("from %s import " % newname)
while True:
- found = fstr.find(fromstr,ind)
+ found = fstr.find(fromstr, ind)
if (found < 0):
break
ind = found + Nlen
@@ -106,16 +106,16 @@ def addimport(astr):
def replaceattr(astr):
astr = astr.replace(".imaginary", ".imag")
- astr = astr.replace(".byteswapped()",".byteswap(False)")
+ astr = astr.replace(".byteswapped()", ".byteswap(False)")
astr = astr.replace(".byteswap()", ".byteswap(True)")
astr = astr.replace(".isaligned()", ".flags.aligned")
- astr = astr.replace(".iscontiguous()",".flags.contiguous")
- astr = astr.replace(".is_fortran_contiguous()",".flags.fortran")
- astr = astr.replace(".itemsize()",".itemsize")
- astr = astr.replace(".size()",".size")
- astr = astr.replace(".nelements()",".size")
- astr = astr.replace(".typecode()",".dtype.char")
- astr = astr.replace(".stddev()",".std()")
+ astr = astr.replace(".iscontiguous()", ".flags.contiguous")
+ astr = astr.replace(".is_fortran_contiguous()", ".flags.fortran")
+ astr = astr.replace(".itemsize()", ".itemsize")
+ astr = astr.replace(".size()", ".size")
+ astr = astr.replace(".nelements()", ".size")
+ astr = astr.replace(".typecode()", ".dtype.char")
+ astr = astr.replace(".stddev()", ".std()")
astr = astr.replace(".getshape()", ".shape")
astr = astr.replace(".getflat()", ".ravel()")
astr = astr.replace(".getreal", ".real")
@@ -123,9 +123,9 @@ def replaceattr(astr):
astr = astr.replace(".getimaginary", ".imag")
# preserve uses of flat that should be o.k.
- tmpstr = flatindex_re.sub(r"@@@@\2",astr)
+ tmpstr = flatindex_re.sub(r"@@@@\2", astr)
# replace other uses of flat
- tmpstr = tmpstr.replace(".flat",".ravel()")
+ tmpstr = tmpstr.replace(".flat", ".ravel()")
# put back .flat where it was valid
astr = tmpstr.replace("@@@@", ".flat")
return astr
@@ -222,7 +222,7 @@ def convertall(direc=os.path.curdir, orig=1):
<usesnumeric>.py.orig. A new file named <usesnumeric>.py
is then written with the updated code.
"""
- files = glob.glob(os.path.join(direc,'*.py'))
+ files = glob.glob(os.path.join(direc, '*.py'))
for afile in files:
if afile[-8:] == 'setup.py': continue
convertfile(afile, orig)
@@ -234,16 +234,16 @@ def convertsrc(direc=os.path.curdir, ext=None, orig=1):
directory with extension give by list ext (if ext is None, then all files are
replaced)."""
if ext is None:
- files = glob.glob(os.path.join(direc,'*'))
+ files = glob.glob(os.path.join(direc, '*'))
else:
files = []
for aext in ext:
- files.extend(glob.glob(os.path.join(direc,"*.%s" % aext)))
+ files.extend(glob.glob(os.path.join(direc, "*.%s" % aext)))
for afile in files:
fid = open(afile)
fstr = fid.read()
fid.close()
- fstr, n = header_re.subn(r'numpy/libnumarray.h',fstr)
+ fstr, n = header_re.subn(r'numpy/libnumarray.h', fstr)
if n > 0:
if orig:
base, ext = os.path.splitext(afile)
@@ -254,7 +254,7 @@ def convertsrc(direc=os.path.curdir, ext=None, orig=1):
def _func(arg, dirname, fnames):
convertall(dirname, orig=0)
- convertsrc(dirname, ['h','c'], orig=0)
+ convertsrc(dirname, ['h', 'c'], orig=0)
def converttree(direc=os.path.curdir):
"""Convert all .py files in the tree given
diff --git a/numpy/numarray/alter_code2.py b/numpy/numarray/alter_code2.py
index 18c604afb..5771a7285 100644
--- a/numpy/numarray/alter_code2.py
+++ b/numpy/numarray/alter_code2.py
@@ -50,7 +50,7 @@ def convertall(direc=os.path.curdir):
<usesnumeric>.py.orig. A new file named <usesnumeric>.py
is then written with the updated code.
"""
- files = glob.glob(os.path.join(direc,'*.py'))
+ files = glob.glob(os.path.join(direc, '*.py'))
for afile in files:
convertfile(afile)
diff --git a/numpy/numarray/functions.py b/numpy/numarray/functions.py
index 78d05e5f5..f37e0f054 100644
--- a/numpy/numarray/functions.py
+++ b/numpy/numarray/functions.py
@@ -107,7 +107,7 @@ def and_(a, b):
def divide_remainder(a, b):
a, b = asarray(a), asarray(b)
- return (a/b,a%b)
+ return (a/b, a%b)
def around(array, digits=0, output=None):
ret = np.around(array, digits, output)
@@ -211,13 +211,13 @@ def fromfile(infile, type=None, shape=None, sizing=STRICT,
##try to estimate file size
try:
curpos=infile.tell()
- infile.seek(0,2)
+ infile.seek(0, 2)
endpos=infile.tell()
infile.seek(curpos)
except (AttributeError, IOError):
initsize=blocksize
else:
- initsize=max(1,(endpos-curpos)//recsize)*recsize
+ initsize=max(1, (endpos-curpos)//recsize)*recsize
buf = np.newbuffer(initsize)
@@ -228,7 +228,7 @@ def fromfile(infile, type=None, shape=None, sizing=STRICT,
break
##do we have space?
if len(buf) < bytesread+blocksize:
- buf=_resizebuf(buf,len(buf)+blocksize)
+ buf=_resizebuf(buf, len(buf)+blocksize)
## or rather a=resizebuf(a,2*len(a)) ?
assert len(buf) >= bytesread+blocksize
buf[bytesread:bytesread+blocksize]=data
@@ -241,7 +241,7 @@ def fromfile(infile, type=None, shape=None, sizing=STRICT,
_warnings.warn("Filesize does not match specified shape",
SizeMismatchWarning)
try:
- infile.seek(-(len(data) % recsize),1)
+ infile.seek(-(len(data) % recsize), 1)
except AttributeError:
_warnings.warn("Could not rewind (no seek support)",
FileSeekWarning)
@@ -250,7 +250,7 @@ def fromfile(infile, type=None, shape=None, sizing=STRICT,
FileSeekWarning)
datasize = (len(data)//recsize) * recsize
if len(buf) != bytesread+datasize:
- buf=_resizebuf(buf,bytesread+datasize)
+ buf=_resizebuf(buf, bytesread+datasize)
buf[bytesread:bytesread+datasize]=data[:datasize]
##deduce shape from len(buf)
shape = list(shape)
@@ -265,7 +265,7 @@ def fromfile(infile, type=None, shape=None, sizing=STRICT,
# this function is referenced in the code above but not defined. adding
# it back. - phensley
-def _resizebuf(buf,newsize):
+def _resizebuf(buf, newsize):
"Return a copy of BUF of size NEWSIZE."
newbuf = np.newbuffer(newsize)
if newsize > len(buf):
@@ -389,7 +389,7 @@ def info(obj, output=sys.stdout, numpy=0):
print("data pointer: %s%s" % (hex(obj.ctypes._as_parameter_.value), extra), file=output)
print("byteorder: ", end=' ', file=output)
endian = obj.dtype.byteorder
- if endian in ['|','=']:
+ if endian in ['|', '=']:
print("%s%s%s" % (tic, sys.byteorder, tic), file=output)
byteswap = False
elif endian == '>':
@@ -472,14 +472,14 @@ def tensormultiply(a1, a2):
raise ValueError("Unmatched dimensions")
shape = a1.shape[:-1] + a2.shape[1:]
return np.reshape(dot(np.reshape(a1, (-1, a1.shape[-1])),
- np.reshape(a2, (a2.shape[0],-1))),
+ np.reshape(a2, (a2.shape[0], -1))),
shape)
def cumsum(a1, axis=0, out=None, type=None, dim=0):
- return np.asarray(a1).cumsum(axis,dtype=type,out=out)
+ return np.asarray(a1).cumsum(axis, dtype=type, out=out)
def cumproduct(a1, axis=0, out=None, type=None, dim=0):
- return np.asarray(a1).cumprod(axis,dtype=type,out=out)
+ return np.asarray(a1).cumprod(axis, dtype=type, out=out)
def argmax(x, axis=-1):
return np.argmax(x, axis)
diff --git a/numpy/numarray/numerictypes.py b/numpy/numarray/numerictypes.py
index 21685c34d..739b855a1 100644
--- a/numpy/numarray/numerictypes.py
+++ b/numpy/numarray/numerictypes.py
@@ -32,17 +32,17 @@ from __future__ import division, absolute_import, print_function
import numpy
from numpy.compat import long
-__all__ = ['NumericType','HasUInt64','typeDict','IsType',
+__all__ = ['NumericType', 'HasUInt64', 'typeDict', 'IsType',
'BooleanType', 'SignedType', 'UnsignedType', 'IntegralType',
'SignedIntegralType', 'UnsignedIntegralType', 'FloatingType',
'ComplexType', 'AnyType', 'ObjectType', 'Any', 'Object',
'Bool', 'Int8', 'Int16', 'Int32', 'Int64', 'Float32',
'Float64', 'UInt8', 'UInt16', 'UInt32', 'UInt64',
- 'Complex32', 'Complex64', 'Byte', 'Short', 'Int','Long',
+ 'Complex32', 'Complex64', 'Byte', 'Short', 'Int', 'Long',
'Float', 'Complex', 'genericTypeRank', 'pythonTypeRank',
'pythonTypeMap', 'scalarTypeMap', 'genericCoercions',
- 'typecodes', 'genericPromotionExclusions','MaximumType',
- 'getType','scalarTypes', 'typefrom']
+ 'typecodes', 'genericPromotionExclusions', 'MaximumType',
+ 'getType', 'scalarTypes', 'typefrom']
MAX_ALIGN = 8
MAX_INT_SIZE = 8
@@ -305,23 +305,23 @@ _scipy_alias("complex64", "Complex32")
# Ranking of types from lowest to highest (sorta)
if not HasUInt64:
- genericTypeRank = ['Bool','Int8','UInt8','Int16','UInt16',
+ genericTypeRank = ['Bool', 'Int8', 'UInt8', 'Int16', 'UInt16',
'Int32', 'UInt32', 'Int64',
- 'Float32','Float64', 'Complex32', 'Complex64', 'Object']
+ 'Float32', 'Float64', 'Complex32', 'Complex64', 'Object']
else:
- genericTypeRank = ['Bool','Int8','UInt8','Int16','UInt16',
+ genericTypeRank = ['Bool', 'Int8', 'UInt8', 'Int16', 'UInt16',
'Int32', 'UInt32', 'Int64', 'UInt64',
- 'Float32','Float64', 'Complex32', 'Complex64', 'Object']
+ 'Float32', 'Float64', 'Complex32', 'Complex64', 'Object']
pythonTypeRank = [ bool, int, long, float, complex ]
# The next line is not platform independent XXX Needs to be generalized
if not LP64:
pythonTypeMap = {
- int:("Int32","int"),
- long:("Int64","int"),
- float:("Float64","float"),
- complex:("Complex64","complex")}
+ int:("Int32", "int"),
+ long:("Int64", "int"),
+ float:("Float64", "float"),
+ complex:("Complex64", "complex")}
scalarTypeMap = {
int:"Int32",
@@ -330,10 +330,10 @@ if not LP64:
complex:"Complex64"}
else:
pythonTypeMap = {
- int:("Int64","int"),
- long:("Int64","int"),
- float:("Float64","float"),
- complex:("Complex64","complex")}
+ int:("Int64", "int"),
+ long:("Int64", "int"),
+ float:("Float64", "float"),
+ complex:("Complex64", "complex")}
scalarTypeMap = {
int:"Int64",
@@ -341,7 +341,7 @@ else:
float:"Float64",
complex:"Complex64"}
-pythonTypeMap.update({bool:("Bool","bool") })
+pythonTypeMap.update({bool:("Bool", "bool") })
scalarTypeMap.update({bool:"Bool"})
# Generate coercion matrix
@@ -415,16 +415,16 @@ def _initGenericCoercions():
genericCoercions[("Complex32", "UInt64")] = "Complex64"
genericCoercions[("UInt64", "Complex32")] = "Complex64"
- genericCoercions[("Int64","Float32")] = "Float64"
+ genericCoercions[("Int64", "Float32")] = "Float64"
genericCoercions[("Float32", "Int64")] = "Float64"
- genericCoercions[("UInt64","Float32")] = "Float64"
+ genericCoercions[("UInt64", "Float32")] = "Float64"
genericCoercions[("Float32", "UInt64")] = "Float64"
genericCoercions[(float, "Bool")] = "Float64"
genericCoercions[("Bool", float)] = "Float64"
- genericCoercions[(float,float,float)] = "Float64" # for scipy.special
- genericCoercions[(int,int,float)] = "Float64" # for scipy.special
+ genericCoercions[(float, float, float)] = "Float64" # for scipy.special
+ genericCoercions[(int, int, float)] = "Float64" # for scipy.special
_initGenericCoercions()
@@ -433,12 +433,12 @@ genericPromotionExclusions = {
'Bool': (),
'Int8': (),
'Int16': (),
- 'Int32': ('Float32','Complex32'),
+ 'Int32': ('Float32', 'Complex32'),
'UInt8': (),
'UInt16': (),
- 'UInt32': ('Float32','Complex32'),
- 'Int64' : ('Float32','Complex32'),
- 'UInt64' : ('Float32','Complex32'),
+ 'UInt32': ('Float32', 'Complex32'),
+ 'Int64' : ('Float32', 'Complex32'),
+ 'UInt64' : ('Float32', 'Complex32'),
'Float32': (),
'Float64': ('Complex32',),
'Complex32':(),
@@ -510,7 +510,7 @@ def getType(type):
except KeyError:
raise TypeError("Not a numeric type")
-scalarTypes = (bool,int,long,float,complex)
+scalarTypes = (bool, int, long, float, complex)
_scipy_dtypechar = {
Int8 : 'b',
@@ -528,7 +528,7 @@ _scipy_dtypechar = {
}
_scipy_dtypechar_inverse = {}
-for key,value in _scipy_dtypechar.items():
+for key, value in _scipy_dtypechar.items():
_scipy_dtypechar_inverse[value] = key
_val = numpy.int_(0).itemsize
diff --git a/numpy/numarray/session.py b/numpy/numarray/session.py
index e40cd4033..7e9c2f1fd 100644
--- a/numpy/numarray/session.py
+++ b/numpy/numarray/session.py
@@ -119,9 +119,9 @@ def _callers_modules():
global namespace."""
g = _callers_globals()
mods = []
- for k,v in g.items():
+ for k, v in g.items():
if isinstance(v, type(sys)):
- mods.append(getattr(v,"__name__"))
+ mods.append(getattr(v, "__name__"))
return mods
def _errout(*args):
@@ -154,7 +154,7 @@ class _ModuleProxy(object):
try:
self = _loadmodule(name)
except ImportError:
- _errout("warning: module", name,"import failed.")
+ _errout("warning: module", name, "import failed.")
return self
def __getnewargs__(self):
@@ -192,13 +192,13 @@ class _ObjectProxy(object):
except (ImportError, KeyError):
_errout("warning: loading object proxy", module + "." + name,
"module import failed.")
- return _ProxyingFailure(module,name,_type2)
+ return _ProxyingFailure(module, name, _type2)
try:
self = getattr(m, name)
except AttributeError:
_errout("warning: object proxy", module + "." + name,
"wouldn't reload from", m)
- return _ProxyingFailure(module,name,_type2)
+ return _ProxyingFailure(module, name, _type2)
return self
def __getnewargs__(self):
@@ -234,7 +234,7 @@ def _locate(modules, object):
for mname in modules:
m = sys.modules[mname]
if m:
- for k,v in m.__dict__.items():
+ for k, v in m.__dict__.items():
if v is object:
return m.__name__, k
else:
@@ -276,7 +276,7 @@ def save(variables=None, file=SAVEFILE, dictionary=None, verbose=False):
p = pickle.Pickler(file, protocol=2)
- _verbose("variables:",keys)
+ _verbose("variables:", keys)
for k in keys:
v = dictionary[k]
_verbose("saving", k, type(v))
@@ -291,7 +291,7 @@ def save(variables=None, file=SAVEFILE, dictionary=None, verbose=False):
try:
module, name = _locate(source_modules, v)
except ObjectNotFound:
- _errout("warning: couldn't find object",k,
+ _errout("warning: couldn't find object", k,
"in any module... skipping.")
continue
else:
diff --git a/numpy/numarray/setup.py b/numpy/numarray/setup.py
index 5c9574917..2c2b804c9 100644
--- a/numpy/numarray/setup.py
+++ b/numpy/numarray/setup.py
@@ -4,7 +4,7 @@ from os.path import join
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
- config = Configuration('numarray',parent_package,top_path)
+ config = Configuration('numarray', parent_package, top_path)
config.add_data_files('include/numpy/*')