Skip to content

Commit

Permalink
PEP8: Fix E502 the backslash is redundant between brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Apr 12, 2013
1 parent d1523ad commit b5ccb04
Show file tree
Hide file tree
Showing 58 changed files with 191 additions and 190 deletions.
2 changes: 1 addition & 1 deletion scipy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
majver, minver = [float(i) for i in _num.version.version.split('.')[:2]]
if majver < 1 or (majver == 1 and minver < 5):
import warnings
warnings.warn("Numpy 1.5.0 or above is recommended for this version of " \
warnings.warn("Numpy 1.5.0 or above is recommended for this version of "
"scipy (detected version %s)" % _num.version.version,
UserWarning)

Expand Down
26 changes: 13 additions & 13 deletions scipy/cluster/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def linkage(y, method='single', metric='euclidean'):
[y] = _copy_arrays_if_base_present([y])

Z = np.zeros((d - 1, 4))
_hierarchy_wrap.linkage_wrap(y, Z, int(d), \
_hierarchy_wrap.linkage_wrap(y, Z, int(d),
int(_cpy_non_euclid_methods[method]))
elif len(s) == 2:
X = y
Expand All @@ -643,7 +643,7 @@ def linkage(y, method='single', metric='euclidean'):
if method in _cpy_non_euclid_methods:
dm = distance.pdist(X, metric)
Z = np.zeros((n - 1, 4))
_hierarchy_wrap.linkage_wrap(dm, Z, n, \
_hierarchy_wrap.linkage_wrap(dm, Z, n,
int(_cpy_non_euclid_methods[method]))
elif method in _cpy_euclid_methods:
if metric != 'euclidean':
Expand Down Expand Up @@ -1560,7 +1560,7 @@ def fcluster(Z, t, criterion='inconsistent', depth=2, R=None, monocrit=None):
return T


def fclusterdata(X, t, criterion='inconsistent', \
def fclusterdata(X, t, criterion='inconsistent',
metric='euclidean', depth=2, method='single', R=None):
"""
Cluster observation data using a given metric.
Expand Down Expand Up @@ -2230,15 +2230,15 @@ def _append_contraction_marks_sub(Z, iv, i, n, contraction_marks):
_append_contraction_marks_sub(Z, iv, Z[i - n, 1], n, contraction_marks)


def _dendrogram_calculate_info(Z, p, truncate_mode, \
color_threshold=np.inf, get_leaves=True, \
orientation='top', labels=None, \
count_sort=False, distance_sort=False, \
show_leaf_counts=False, i=-1, iv=0.0, \
ivl=[], n=0, icoord_list=[], dcoord_list=[], \
lvs=None, mhr=False, \
current_color=[], color_list=[], \
currently_below_threshold=[], \
def _dendrogram_calculate_info(Z, p, truncate_mode,
color_threshold=np.inf, get_leaves=True,
orientation='top', labels=None,
count_sort=False, distance_sort=False,
show_leaf_counts=False, i=-1, iv=0.0,
ivl=[], n=0, icoord_list=[], dcoord_list=[],
lvs=None, mhr=False,
current_color=[], color_list=[],
currently_below_threshold=[],
leaf_label_func=None, level=0,
contraction_marks=None,
link_color_func=None):
Expand Down Expand Up @@ -2724,7 +2724,7 @@ def _leader_identify(tr, T):
right = tr.get_right()
lfid = _leader_identify(left, T)
rfid = _leader_identify(right, T)
print('ndid: %d lid: %d lfid: %d rid: %d rfid: %d' \
print('ndid: %d lid: %d lfid: %d rid: %d rfid: %d'
% (tr.get_id(), left.get_id(), lfid, right.get_id(), rfid))
if lfid != rfid:
if lfid != -1:
Expand Down
4 changes: 2 additions & 2 deletions scipy/cluster/vq.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def py_vq(obs, code_book):
if not np.ndim(obs) == np.ndim(code_book):
raise ValueError("Observation and code_book should have the same rank")
elif not d == code_book.shape[1]:
raise ValueError("Code book(%d) and obs(%d) should have the same " \
raise ValueError("Code book(%d) and obs(%d) should have the same "
"number of features (eg columns)""" %
(code_book.shape[1], d))

Expand Down Expand Up @@ -496,7 +496,7 @@ def kmeans(obs, k_or_guess, iter=20, thresh=1e-5):
if type(k_or_guess) == type(array([])):
guess = k_or_guess
if guess.size < 1:
raise ValueError("Asked for 0 cluster ? initial book was %s" % \
raise ValueError("Asked for 0 cluster ? initial book was %s" %
guess)
result = _kmeans(obs, guess, thresh=thresh)
else:
Expand Down
2 changes: 1 addition & 1 deletion scipy/constants/codata.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ def find(sub=None, disp=False):
if sub is None:
result = list(_current_constants.keys())
else:
result = [key for key in _current_constants \
result = [key for key in _current_constants
if sub.lower() in key.lower()]

result.sort()
Expand Down
2 changes: 1 addition & 1 deletion scipy/fftpack/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def _raw_fftnd(x, s, axes, direction, overwrite_x, work_function):
else:
noaxes = False
if len(axes) != len(s):
raise ValueError("when given, axes and shape arguments "\
raise ValueError("when given, axes and shape arguments "
"have to be of the same length")

for dim in s:
Expand Down
6 changes: 3 additions & 3 deletions scipy/fftpack/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def test_shape_axes_argument(self):
y = fftn(small_x,shape=(4,4),axes=(-2,-1))
assert_array_almost_equal(y,fftn(large_x1))
y = fftn(small_x,shape=(4,4),axes=(-1,-2))
assert_array_almost_equal(y,swapaxes(\
assert_array_almost_equal(y,swapaxes(
fftn(swapaxes(large_x1,-1,-2)),-1,-2))

def test_shape_axes_argument2(self):
Expand Down Expand Up @@ -634,7 +634,7 @@ def test_complex(self):
for f in [fft, ifft]:
try:
f(x)
raise AssertionError("Type %r not supported but does not fail" % \
raise AssertionError("Type %r not supported but does not fail" %
np.longcomplex)
except ValueError:
pass
Expand All @@ -649,7 +649,7 @@ def test_real(self):
for f in [fft, ifft]:
try:
f(x)
raise AssertionError("Type %r not supported but does not fail" % \
raise AssertionError("Type %r not supported but does not fail" %
np.longcomplex)
except ValueError:
pass
Expand Down
6 changes: 3 additions & 3 deletions scipy/integrate/quadrature.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ def _basic_simps(y,start,stop,x,dx,axis):
hsum = h0 + h1
hprod = h0 * h1
h0divh1 = h0 / h1
result = add.reduce(hsum/6.0*(y[slice0]*(2-1.0/h0divh1) + \
y[slice1]*hsum*hsum/hprod + \
result = add.reduce(hsum/6.0*(y[slice0]*(2-1.0/h0divh1) +
y[slice1]*hsum*hsum/hprod +
y[slice2]*(2-h0divh1)),axis)
return result

Expand Down Expand Up @@ -452,7 +452,7 @@ def romb(y, dx=1.0, axis=-1, show=False):

if show:
if not isscalar(R[(1,1)]):
print("*** Printing table only supported for integrals" + \
print("*** Printing table only supported for integrals" +
" of a single data set.")
else:
try:
Expand Down
8 changes: 4 additions & 4 deletions scipy/interpolate/fitpack2.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,12 +706,12 @@ def __init__(self, x, y, z, tx, ty, w=None, bbox=[None]*4, kx=3, ky=3,
ty1[ky+1:ny-ky-1] = ty

xb,xe,yb,ye = bbox
tx1,ty1,c,fp,ier = dfitpack.surfit_lsq(x,y,z,tx1,ty1,w,\
xb,xe,yb,ye,\
tx1,ty1,c,fp,ier = dfitpack.surfit_lsq(x,y,z,tx1,ty1,w,
xb,xe,yb,ye,
kx,ky,eps,lwrk2=1)
if ier>10:
tx1,ty1,c,fp,ier = dfitpack.surfit_lsq(x,y,z,tx1,ty1,w,\
xb,xe,yb,ye,\
tx1,ty1,c,fp,ier = dfitpack.surfit_lsq(x,y,z,tx1,ty1,w,
xb,xe,yb,ye,
kx,ky,eps,lwrk2=ier)
if ier in [0,-1,-2]: # normal return
pass
Expand Down
2 changes: 1 addition & 1 deletion scipy/interpolate/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def __init__(self, x, y, kind='linear', axis=-1,
order = kind
kind = 'spline'
elif kind not in ('linear', 'nearest'):
raise NotImplementedError("%s is unsupported: Use fitpack "\
raise NotImplementedError("%s is unsupported: Use fitpack "
"routines for other types." % kind)
x = array(x, copy=self.copy)
y = array(y, copy=self.copy)
Expand Down
4 changes: 2 additions & 2 deletions scipy/interpolate/tests/test_fitpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def check_3(self,f=f1,per=0,s=0,a=0,b=2*pi,N=20,xb=None,xe=None,
x=a+(b-a)*arange(N+1,dtype=float)/float(N) # nodes
v=f(x)
nk=[]
put(" k : Roots of s(x) approx %s x in [%s,%s]:"%\
put(" k : Roots of s(x) approx %s x in [%s,%s]:"%
(f(None),repr(round(a,3)),repr(round(b,3))))
for k in range(1,6):
tck=splrep(x,v,s=s,per=per,k=k,xe=xe)
Expand Down Expand Up @@ -164,7 +164,7 @@ def check_4(self,f=f1,per=0,s=0,a=0,b=2*pi,N=20,xb=None,xe=None,
err2 = abs(splev(uv[0],tck)-f(uv[0]))
assert_(err1 < 1e-2)
assert_(err2 < 1e-2)
put(" %d : %s %.1e %.1e"%\
put(" %d : %s %.1e %.1e"%
(k,repr([round(z,3) for z in uv]),
err1,
err2))
Expand Down
2 changes: 1 addition & 1 deletion scipy/io/arff/arffread.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def tokenize_multilines(iterable, val):
m = r_comattrval.match("".join(all[:-1]))
return m.group(1), m.group(2), i
else:
raise ValueError("Cannot parse attribute names spread over multi "\
raise ValueError("Cannot parse attribute names spread over multi "
"lines yet")


Expand Down
6 changes: 3 additions & 3 deletions scipy/io/harwell_boeing/_fortran_format_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def next_token(self):
self.curpos = m.end()
return Token(self.tokens[i], m.group(), self.curpos)
else:
raise SyntaxError("Unknown character at position %d (%s)" \
raise SyntaxError("Unknown character at position %d (%s)"
% (self.curpos, self.data[curpos]))


Expand Down Expand Up @@ -264,10 +264,10 @@ def _expect(self, token, tp):

def _parse_format(self, tokens):
if not tokens[0].type == "LPAR":
raise SyntaxError("Expected left parenthesis at position "\
raise SyntaxError("Expected left parenthesis at position "
"%d (got '%s')" % (0, tokens[0].value))
elif not tokens[-1].type == "RPAR":
raise SyntaxError("Expected right parenthesis at position "\
raise SyntaxError("Expected right parenthesis at position "
"%d (got '%s')" % (len(tokens), tokens[-1].value))

tokens = tokens[1:-1]
Expand Down
10 changes: 5 additions & 5 deletions scipy/io/harwell_boeing/hb.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def from_data(cls, m, title="Default title", key="0", mxtype=None, fmt=None):
elif values.dtype.kind in np.typecodes["AllFloat"]:
tp = "real"
else:
raise NotImplementedError("type %s for values not implemented" \
raise NotImplementedError("type %s for values not implemented"
% values.dtype)
mxtype = HBMatrixType(tp, "unsymmetric", "assembled")
else:
Expand Down Expand Up @@ -160,7 +160,7 @@ def from_file(cls, fid):
else:
rhs_nlines = _expect_int(rhs_nlines)
if not rhs_nlines == 0:
raise ValueError("Only files without right hand side supported for " \
raise ValueError("Only files without right hand side supported for "
"now.")

# Third line
Expand Down Expand Up @@ -245,12 +245,12 @@ def __init__(self, title, key,
values_format = parser.parse(values_format_str)
if isinstance(values_format, ExpFormat):
if not mxtype.value_type in ["real", "complex"]:
raise ValueError("Inconsistency between matrix type %s and " \
raise ValueError("Inconsistency between matrix type %s and "
"value type %s" % (mxtype, values_format))
values_dtype = np.float64
elif isinstance(values_format, IntFormat):
if not mxtype.value_type in ["integer"]:
raise ValueError("Inconsistency between matrix type %s and " \
raise ValueError("Inconsistency between matrix type %s and "
"value type %s" % (mxtype, values_format))
# XXX: fortran int -> dtype association ?
values_dtype = np.int
Expand Down Expand Up @@ -387,7 +387,7 @@ class HBMatrixType(object):
@classmethod
def from_fortran(cls, fmt):
if not len(fmt) == 3:
raise ValueError("Fortran format for matrix type should be 3 " \
raise ValueError("Fortran format for matrix type should be 3 "
"characters long")
try:
value_type = cls._f2q_type[fmt[0]]
Expand Down
18 changes: 9 additions & 9 deletions scipy/io/idl.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ def _read_structure(f, array_desc, struct_desc):
for col in columns:
dtype = col['typecode']
if col['structure']:
structure[col['name']][i] = _read_structure(f, \
struct_desc['arrtable'][col['name']], \
structure[col['name']][i] = _read_structure(f,
struct_desc['arrtable'][col['name']],
struct_desc['structtable'][col['name']])
elif col['array']:
structure[col['name']][i] = _read_array(f, dtype, \
structure[col['name']][i] = _read_array(f, dtype,
struct_desc['arrtable'][col['name']])
else:
structure[col['name']][i] = _read_data(f, dtype)
Expand Down Expand Up @@ -285,14 +285,14 @@ def _read_array(f, typecode, array_desc):
raise Exception("Error occurred while reading byte array")

# Read bytes as numpy array
array = np.fromstring(f.read(array_desc['nbytes']), \
array = np.fromstring(f.read(array_desc['nbytes']),
dtype=DTYPE_DICT[typecode])

elif typecode in [2, 12]:

# These are 2 byte types, need to skip every two as they are not packed

array = np.fromstring(f.read(array_desc['nbytes']*2), \
array = np.fromstring(f.read(array_desc['nbytes']*2),
dtype=DTYPE_DICT[typecode])[1::2]

else:
Expand Down Expand Up @@ -351,10 +351,10 @@ def _read_record(f):
raise Exception("VARSTART is not 7")

if rectypedesc['structure']:
record['data'] = _read_structure(f, rectypedesc['array_desc'], \
record['data'] = _read_structure(f, rectypedesc['array_desc'],
rectypedesc['struct_desc'])
elif rectypedesc['array']:
record['data'] = _read_array(f, rectypedesc['typecode'], \
record['data'] = _read_array(f, rectypedesc['typecode'],
rectypedesc['array_desc'])
else:
dtype = rectypedesc['typecode']
Expand Down Expand Up @@ -413,7 +413,7 @@ def _read_record(f):

else:

raise Exception("record['rectype']=%s not implemented" % \
raise Exception("record['rectype']=%s not implemented" %
record['rectype'])

f.seek(nextrec)
Expand Down Expand Up @@ -846,7 +846,7 @@ def readsav(file_name, idict=None, python_dict=False,
break

print("-"*50)
print("Successfully read %i records of which:" % \
print("Successfully read %i records of which:" %
(len(records)))

# Create convenience list of record types
Expand Down
2 changes: 1 addition & 1 deletion scipy/io/matlab/mio5.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def get_variables(self, variable_names=None):
res = self.read_var_array(hdr, process)
except MatReadError as err:
warnings.warn(
'Unreadable variable "%s", because "%s"' % \
'Unreadable variable "%s", because "%s"' %
(name, err),
Warning, stacklevel=2)
res = "Read error: %s" % err
Expand Down
2 changes: 1 addition & 1 deletion scipy/io/matlab/tests/test_mio.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def _check_level(label, expected, actual):
decimal=5)
return
# Check types are as expected
assert_true(types_compatible(expected, actual), \
assert_true(types_compatible(expected, actual),
"Expected type %s, got %s at %s" %
(type(expected), type(actual), label))
# A field in a record array may not be an ndarray
Expand Down
2 changes: 1 addition & 1 deletion scipy/lib/blas/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def configuration(parent_package='',top_path=None):

blas_opt = get_info('blas_opt',notfound_action=2)

atlas_version = ([v[3:-3] for k,v in blas_opt.get('define_macros',[]) \
atlas_version = ([v[3:-3] for k,v in blas_opt.get('define_macros',[])
if k=='ATLAS_INFO']+[None])[0]
if atlas_version:
print(('ATLAS version: %s' % atlas_version))
Expand Down
2 changes: 1 addition & 1 deletion scipy/lib/lapack/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def configuration(parent_package='',top_path=None):

lapack_opt = get_info('lapack_opt',notfound_action=2)

atlas_version = ([v[3:-3] for k,v in lapack_opt.get('define_macros',[]) \
atlas_version = ([v[3:-3] for k,v in lapack_opt.get('define_macros',[])
if k=='ATLAS_INFO']+[None])[0]
if atlas_version:
print(('ATLAS version: %s' % atlas_version))
Expand Down
2 changes: 1 addition & 1 deletion scipy/linalg/decomp_qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def rq(a, overwrite_a=False, lwork=None, mode='full', check_finite=True):
"""
if not mode in ['full', 'r', 'economic']:
raise ValueError(\
raise ValueError(
"Mode argument should be one of ['full', 'r', 'economic']")

if check_finite:
Expand Down
2 changes: 1 addition & 1 deletion scipy/linalg/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def configuration(parent_package='',top_path=None):
if not lapack_opt:
raise NotFoundError('no lapack/blas resources found')

atlas_version = ([v[3:-3] for k,v in lapack_opt.get('define_macros',[]) \
atlas_version = ([v[3:-3] for k,v in lapack_opt.get('define_macros',[])
if k=='ATLAS_INFO']+[None])[0]
if atlas_version:
print(('ATLAS version: %s' % atlas_version))
Expand Down
2 changes: 1 addition & 1 deletion scipy/misc/pilutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def toimage(arr, high=255, low=0, cmin=None, cmax=None, pal=None,
if iscomplexobj(data):
raise ValueError("Cannot convert a complex-valued array.")
shape = list(data.shape)
valid = len(shape)==2 or ((len(shape)==3) and \
valid = len(shape)==2 or ((len(shape)==3) and
((3 in shape) or (4 in shape)))
if not valid:
raise ValueError("'arr' does not have a suitable array shape for any mode.")
Expand Down
Loading

0 comments on commit b5ccb04

Please sign in to comment.