Skip to content

Commit

Permalink
PEP8: Fix E228 missing whitespace around modulo operator
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Apr 12, 2013
1 parent e28f787 commit 18145d3
Show file tree
Hide file tree
Showing 26 changed files with 126 additions and 126 deletions.
4 changes: 2 additions & 2 deletions scipy/fftpack/benchmarks/bench_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def bench_random(self):
x1[0] = x[0]
for i in range(1,size/2):
x1[i] = x[2*i-1] + 1j * x[2*i]
if not size%2:
if not size % 2:
x1[-1] = x[-1]
y = irfft(x)

Expand Down Expand Up @@ -196,7 +196,7 @@ def bench_random(self):
((256,256),10),
((512,512),3),
]:
print('%9s' % ('%sx%s'%size), end=' ')
print('%9s' % ('%sx%s' % size), end=' ')
sys.stdout.flush()

for x in [random(size).astype(double),
Expand Down
2 changes: 1 addition & 1 deletion scipy/fftpack/pseudo_diffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def kernel(k,order=order,c=c):
zero_nyquist=1)
_cache[(n,order,c)] = omega
overwrite_x = _datacopied(tmp, x)
return convolve.convolve(tmp,omega,swap_real_imag=order%2,
return convolve.convolve(tmp,omega,swap_real_imag=order % 2,
overwrite_x=overwrite_x)
del _cache

Expand Down
2 changes: 1 addition & 1 deletion scipy/integrate/quadrature.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ def newton_cotes(rn, equal=0):
vec = 2.0/ (nvec[::2]+1)
ai = np.dot(Cinv[:,::2],vec) * N/2

if (N%2 == 0) and equal:
if (N % 2 == 0) and equal:
BN = N/(N+3.)
power = N+2
else:
Expand Down
12 changes: 6 additions & 6 deletions scipy/interpolate/fitpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def splprep(x,w=None,u=None,ub=None,ue=None,k=3,task=0,s=None,t=None,
if per:
for i in range(idim):
if x[i][0]!=x[i][-1]:
if quiet<2:print('Warning: Setting x[%d][%d]=x[%d][0]'%(i,m,i))
if quiet<2:print('Warning: Setting x[%d][%d]=x[%d][0]' % (i,m,i))
x[i][-1]=x[i][0]
if not 0 < idim < 11:
raise TypeError('0 < idim < 11 must hold')
Expand Down Expand Up @@ -272,7 +272,7 @@ def splprep(x,w=None,u=None,ub=None,ue=None,k=3,task=0,s=None,t=None,
tcku = [t,list(c),k],u
if ier<=0 and not quiet:
print(_iermess[ier][0])
print("\tk=%d n=%d m=%d fp=%f s=%f"%(k,len(t),m,fp,s))
print("\tk=%d n=%d m=%d fp=%f s=%f" % (k,len(t),m,fp,s))
if ier>0 and not full_output:
if ier in [1,2,3]:
print("Warning: "+_iermess[ier][0])
Expand Down Expand Up @@ -456,7 +456,7 @@ def splrep(x,y,w=None,xb=None,xe=None,k=3,task=0,s=None,t=None,
tck = (t[:n],c[:n],k)
if ier<=0 and not quiet:
print(_iermess[ier][0])
print("\tk=%d n=%d m=%d fp=%f s=%f"%(k,len(t),m,fp,s))
print("\tk=%d n=%d m=%d fp=%f s=%f" % (k,len(t),m,fp,s))
if ier>0 and not full_output:
if ier in [1,2,3]:
print("Warning: "+_iermess[ier][0])
Expand Down Expand Up @@ -540,7 +540,7 @@ def splev(x, tck, der=0, ext=0):
return list(map(lambda c, x=x, t=t, k=k, der=der : splev(x, [t,c,k], der, ext), c))
else:
if not (0 <= der <= k):
raise ValueError("0<=der=%d<=k=%d must hold"%(der,k))
raise ValueError("0<=der=%d<=k=%d must hold" % (der,k))
if not ext in (0,1,2):
raise ValueError("ext not in (0, 1, 2)")

Expand Down Expand Up @@ -882,12 +882,12 @@ def bisplrep(x,y,z,w=None,xb=None,xe=None,yb=None,ye=None,kx=3,ky=3,task=0,
ierm=min(11,max(-3,ier))
if ierm<=0 and not quiet:
print(_iermess2[ierm][0])
print("\tkx,ky=%d,%d nx,ny=%d,%d m=%d fp=%f s=%f"%(kx,ky,len(tx),
print("\tkx,ky=%d,%d nx,ny=%d,%d m=%d fp=%f s=%f" % (kx,ky,len(tx),
len(ty),m,fp,s))
if ierm>0 and not full_output:
if ier in [1,2,3,4,5]:
print("Warning: "+_iermess2[ierm][0])
print("\tkx,ky=%d,%d nx,ny=%d,%d m=%d fp=%f s=%f"%(kx,ky,len(tx),
print("\tkx,ky=%d,%d nx,ny=%d,%d m=%d fp=%f s=%f" % (kx,ky,len(tx),
len(ty),m,fp,s))
else:
try:
Expand Down
2 changes: 1 addition & 1 deletion scipy/interpolate/polyint.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def approximate_taylor_polynomial(f,x,degree,scale,order=None):
# a way that avoids the Runge phenomenon. Ensure, by including the
# endpoint or not as appropriate, that one point always falls at x
# exactly.
xs = scale*np.cos(np.linspace(0,np.pi,n,endpoint=n%1)) + x
xs = scale*np.cos(np.linspace(0,np.pi,n,endpoint=n % 1)) + x

P = KroghInterpolator(xs, f(xs))
d = P.derivatives(x,der=degree+1)
Expand Down
40 changes: 20 additions & 20 deletions scipy/interpolate/tests/test_fitpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ def norm2(x):
def f1(x,d=0):
if d is None: return "sin"
if x is None: return "sin(x)"
if d%4 == 0: return sin(x)
if d%4 == 1: return cos(x)
if d%4 == 2: return -sin(x)
if d%4 == 3: return -cos(x)
if d % 4 == 0: return sin(x)
if d % 4 == 1: return cos(x)
if d % 4 == 2: return -sin(x)
if d % 4 == 3: return -cos(x)

def f2(x,y=0,dx=0,dy=0):
if x is None: return "sin(x+y)"
d=dx+dy
if d%4 == 0: return sin(x+y)
if d%4 == 1: return cos(x+y)
if d%4 == 2: return -sin(x+y)
if d%4 == 3: return -cos(x+y)
if d % 4 == 0: return sin(x+y)
if d % 4 == 1: return cos(x+y)
if d % 4 == 2: return -sin(x+y)
if d % 4 == 3: return -cos(x+y)

def makepairs(x, y):
"""Helper function to create an array of pairs of x and y."""
Expand Down Expand Up @@ -72,20 +72,20 @@ def err_est(k, d):
assert_(err < tol, (k, d, err, tol))
nd.append((err, tol))
nk.append(nd)
put("\nf = %s s=S_k(x;t,c) x in [%s, %s] > [%s, %s]"%(f(None),
put("\nf = %s s=S_k(x;t,c) x in [%s, %s] > [%s, %s]" % (f(None),
repr(round(xb,3)),repr(round(xe,3)),
repr(round(a,3)),repr(round(b,3))))
if at:
str="at knots"
else:
str="at the middle of nodes"
put(" per=%d s=%s Evaluation %s"%(per,repr(s),str))
put(" per=%d s=%s Evaluation %s" % (per,repr(s),str))
put(" k : |f-s|^2 |f'-s'| |f''-.. |f'''-. |f''''- |f'''''")
k=1
for l in nk:
put(' %d : '%k)
put(' %d : ' % k)
for r in l:
put(' %.1e %.1e'%r)
put(' %.1e %.1e' % r)
put('\n')
k=k+1

Expand All @@ -108,23 +108,23 @@ def err_est(k, d):
for k in range(1,6):
tck=splrep(x,v,s=s,per=per,k=k,xe=xe)
nk.append([splint(ia,ib,tck),spalde(dx,tck)])
put("\nf = %s s=S_k(x;t,c) x in [%s, %s] > [%s, %s]"%(f(None),
put("\nf = %s s=S_k(x;t,c) x in [%s, %s] > [%s, %s]" % (f(None),
repr(round(xb,3)),repr(round(xe,3)),
repr(round(a,3)),repr(round(b,3))))
put(" per=%d s=%s N=%d [a, b] = [%s, %s] dx=%s"%(per,repr(s),N,repr(round(ia,3)),repr(round(ib,3)),repr(round(dx,3))))
put(" per=%d s=%s N=%d [a, b] = [%s, %s] dx=%s" % (per,repr(s),N,repr(round(ia,3)),repr(round(ib,3)),repr(round(dx,3))))
put(" k : int(s,[a,b]) Int.Error Rel. error of s^(d)(dx) d = 0, .., k")
k=1
for r in nk:
if r[0]<0: sr='-'
else: sr=' '
put(" %d %s%.8f %.1e "%(k,sr,abs(r[0]),
put(" %d %s%.8f %.1e " % (k,sr,abs(r[0]),
abs(r[0]-(f(ib,-1)-f(ia,-1)))))
d=0
for dr in r[1]:
err = abs(1-dr/f(dx,d))
tol = err_est(k, d)
assert_(err < tol, (k, d))
put(" %.1e %.1e"%(err, tol))
put(" %.1e %.1e" % (err, tol))
d=d+1
put("\n")
k=k+1
Expand All @@ -144,7 +144,7 @@ def check_3(self,f=f1,per=0,s=0,a=0,b=2*pi,N=20,xb=None,xe=None,
if k == 3:
assert_allclose(roots, pi*array([1, 2, 3, 4]),
rtol=1e-3)
put(' %d : %s'%(k,repr(roots.tolist())))
put(' %d : %s' % (k,repr(roots.tolist())))

def check_4(self,f=f1,per=0,s=0,a=0,b=2*pi,N=20,xb=None,xe=None,
ia=0,ib=2*pi,dx=0.2*pi):
Expand All @@ -154,8 +154,8 @@ def check_4(self,f=f1,per=0,s=0,a=0,b=2*pi,N=20,xb=None,xe=None,
x1=a+(b-a)*arange(1,N,dtype=float)/float(N-1) # middle points of the nodes
v,v1=f(x),f(x1)
nk=[]
put(" u = %s N = %d"%(repr(round(dx,3)),N))
put(" k : [x(u), %s(x(u))] Error of splprep Error of splrep "%(f(0,None)))
put(" u = %s N = %d" % (repr(round(dx,3)),N))
put(" k : [x(u), %s(x(u))] Error of splprep Error of splrep " % (f(0,None)))
for k in range(1,6):
tckp,u=splprep([x,v],s=s,per=per,k=k,nest=-1)
tck=splrep(x,v,s=s,per=per,k=k)
Expand All @@ -173,7 +173,7 @@ def check_4(self,f=f1,per=0,s=0,a=0,b=2*pi,N=20,xb=None,xe=None,
tckp,u=splprep([x,v],s=s,per=per,k=k,nest=-1)
for d in range(1,k+1):
uv=splev(dx,tckp,d)
put(" %s "%(repr(uv[0])))
put(" %s " % (repr(uv[0])))

def check_5(self,f=f2,kx=3,ky=3,xb=0,xe=2*pi,yb=0,ye=2*pi,Nx=20,Ny=20,s=0):
x=xb+(xe-xb)*arange(Nx+1,dtype=float)/float(Nx)
Expand Down
2 changes: 1 addition & 1 deletion scipy/interpolate/tests/test_polyint.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def check_shape(interpolator_cls, x_shape, y_shape, deriv_shape=None, axis=0):
# check also values
if xi.size > 0 and deriv_shape is None:
bs_shape = (y.shape[:axis] + ((1,)*len(x_shape)) + y.shape[axis:][1:])
yv = y[((slice(None,None,None),)*(axis%y.ndim))+(1,)].reshape(bs_shape)
yv = y[((slice(None,None,None),)*(axis % y.ndim))+(1,)].reshape(bs_shape)

yi, y = np.broadcast_arrays(yi, yv)
assert_allclose(yi, y)
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 @@ -765,7 +765,7 @@ def _write_items(self, arr):
% (max_length-1))
self.write_element(np.array([length], dtype='i4'))
self.write_element(
np.array(fieldnames, dtype='S%d'%(length)),
np.array(fieldnames, dtype='S%d' % (length)),
mdtype=miINT8)
A = np.atleast_2d(arr).flatten('F')
for el in A:
Expand Down
8 changes: 4 additions & 4 deletions scipy/optimize/benchmarks/bench_zeros.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ def bench_run(self):
print(description)

print('TESTING SPEED\n')
print('times in seconds for %d iterations \n'%repeat)
print('times in seconds for %d iterations \n' % repeat)
for i in range(len(functions)) :
print('function %s\n'%fstrings[i])
print('function %s\n' % fstrings[i])
func = functions[i]
for j in range(len(methods)) :
meth = methods[j]
try:
t = measure("meth(func,a,b)",repeat)
except:
print('%s : failed'%mstrings[j])
print('%s : failed' % mstrings[j])
else:
print('%s : %5.3f'%(mstrings[j],t))
print('%s : %5.3f' % (mstrings[j],t))
print('\n\n')

if __name__ == '__main__' :
Expand Down
6 changes: 3 additions & 3 deletions scipy/optimize/tests/test_minpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_basic(self):
p0 = array([0,0,0])
params_fit, ier = leastsq(self.residuals, p0,
args=(self.y_meas, self.x))
assert_(ier in (1,2,3,4), 'solution not found (ier=%d)'%ier)
assert_(ier in (1,2,3,4), 'solution not found (ier=%d)' % ier)
# low precision due to random
assert_array_almost_equal(params_fit, self.abc, decimal=2)

Expand All @@ -211,7 +211,7 @@ def test_full_output(self):
args=(self.y_meas, self.x),
full_output=True)
params_fit, cov_x, infodict, mesg, ier = full_output
assert_(ier in (1,2,3,4), 'solution not found: %s'%mesg)
assert_(ier in (1,2,3,4), 'solution not found: %s' % mesg)

def test_input_untouched(self):
p0 = array([0,0,0],dtype=float64)
Expand All @@ -220,7 +220,7 @@ def test_input_untouched(self):
args=(self.y_meas, self.x),
full_output=True)
params_fit, cov_x, infodict, mesg, ier = full_output
assert_(ier in (1,2,3,4), 'solution not found: %s'%mesg)
assert_(ier in (1,2,3,4), 'solution not found: %s' % mesg)
assert_array_equal(p0, p0_copy)

def test_wrong_shape_func_callable(self):
Expand Down
6 changes: 3 additions & 3 deletions scipy/sparse/linalg/isolve/lsqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ def lsqr(A, b, damp=0.0, atol=1e-8, btol=1e-8, conlim=1e8,
print('LSQR Least-squares solution of Ax = b')
str1 = 'The matrix A has %8g rows and %8g cols' % (m, n)
str2 = 'damp = %20.14e calc_var = %8g' % (damp, calc_var)
str3 = 'atol = %8.2e conlim = %8.2e'%( atol, conlim)
str4 = 'btol = %8.2e iter_lim = %8g' %( btol, iter_lim)
str3 = 'atol = %8.2e conlim = %8.2e' % ( atol, conlim)
str4 = 'btol = %8.2e iter_lim = %8g' % ( btol, iter_lim)
print(str1)
print(str2)
print(str3)
Expand Down Expand Up @@ -333,7 +333,7 @@ def lsqr(A, b, damp=0.0, atol=1e-8, btol=1e-8, conlim=1e8,
test1 = 1
test2 = alfa / beta
str1 = '%6g %12.5e' %( itn, x[0] )
str2 = ' %10.3e %10.3e'%( r1norm, r2norm )
str2 = ' %10.3e %10.3e' % ( r1norm, r2norm )
str3 = ' %8.1e %8.1e' %( test1, test2 )
print(str1, str2, str3)

Expand Down
4 changes: 2 additions & 2 deletions scipy/stats/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ def _construct_default_doc(self, longname=None, extradoc=None):
extradoc = ''
if extradoc.startswith('\n\n'):
extradoc = extradoc[2:]
self.__doc__ = ''.join(['%s continuous random variable.'%longname,
self.__doc__ = ''.join(['%s continuous random variable.' % longname,
'\n\n%(before_notes)s\n', docheaders['notes'],
extradoc, '\n%(example)s'])
self._construct_doc()
Expand Down Expand Up @@ -5842,7 +5842,7 @@ def _construct_default_doc(self, longname=None, extradoc=None):
extradoc = ''
if extradoc.startswith('\n\n'):
extradoc = extradoc[2:]
self.__doc__ = ''.join(['%s discrete random variable.'%longname,
self.__doc__ = ''.join(['%s discrete random variable.' % longname,
'\n\n%(before_notes)s\n', docheaders['notes'],
extradoc, '\n%(example)s'])
self._construct_doc()
Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/morestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def ppcc_max(x, brack=(0.0,1.0), dist='tukeylambda'):
See also ppcc_plot
"""
try:
ppf_func = eval('distributions.%s.ppf'%dist)
ppf_func = eval('distributions.%s.ppf' % dist)
except AttributeError:
raise ValueError("%s is not a valid distribution with a ppf." % dist)
"""
Expand Down
4 changes: 2 additions & 2 deletions scipy/stats/tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def test_all_distributions():

def check_vonmises_pdf_periodic(k,l,s,x):
vm = stats.vonmises(k,loc=l,scale=s)
assert_almost_equal(vm.pdf(x),vm.pdf(x%(2*numpy.pi*s)))
assert_almost_equal(vm.pdf(x),vm.pdf(x % (2*numpy.pi*s)))
def check_vonmises_cdf_periodic(k,l,s,x):
vm = stats.vonmises(k,loc=l,scale=s)
assert_almost_equal(vm.cdf(x)%1,vm.cdf(x%(2*numpy.pi*s))%1)
assert_almost_equal(vm.cdf(x) % 1,vm.cdf(x % (2*numpy.pi*s)) % 1)

def test_vonmises_pdf_periodic():
for k in [0.1, 1, 101]:
Expand Down
4 changes: 2 additions & 2 deletions scipy/stats/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2059,10 +2059,10 @@ def test_binomtest():

for p, res in zip(pp,results):
assert_approx_equal(stats.binom_test(x, n, p), res,
significant=12, err_msg='fail forp=%f'%p)
significant=12, err_msg='fail forp=%f' % p)

assert_approx_equal(stats.binom_test(50,100,0.1), 5.8320387857343647e-024,
significant=12, err_msg='fail forp=%f'%p)
significant=12, err_msg='fail forp=%f' % p)

class Test_Trim(object):
# test trim functions
Expand Down
Loading

0 comments on commit 18145d3

Please sign in to comment.