Skip to content

Commit

Permalink
PEP8: Fix E222 multiple spaces after operator
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Apr 13, 2013
1 parent f26247a commit 9b1bf5b
Show file tree
Hide file tree
Showing 37 changed files with 78 additions and 78 deletions.
2 changes: 1 addition & 1 deletion scipy/io/harwell_boeing/hb.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def _expect_int(value, msg=None):

def _read_hb_data(content, header):
# XXX: look at a way to reduce memory here (big string creation)
ptr_string = "".join([content.read(header.pointer_nbytes_full),
ptr_string = "".join([content.read(header.pointer_nbytes_full),
content.readline()])
ptr = np.fromstring(ptr_string,
dtype=np.int, sep=' ')
Expand Down
4 changes: 2 additions & 2 deletions scipy/io/matlab/mio5.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def read_var_header(self):
else:
self._matrix_reader.set_stream(self.mat_stream)
if not mdtype == miMATRIX:
raise TypeError('Expecting miMATRIX type here, got %d' % mdtype)
raise TypeError('Expecting miMATRIX type here, got %d' % mdtype)
header = self._matrix_reader.read_header()
return header, next_pos

Expand Down Expand Up @@ -823,7 +823,7 @@ def __init__(self, file_stream,

def write_file_header(self):
# write header
hdr = np.zeros((), NDT_FILE_HDR)
hdr = np.zeros((), NDT_FILE_HDR)
hdr['description']='MATLAB 5.0 MAT-file Platform: %s, Created on: %s' \
% (os.name,time.asctime())
hdr['version']= 0x0100
Expand Down
4 changes: 2 additions & 2 deletions scipy/linalg/matfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ def signm(a, disp=True):
def rounded_sign(x):
rx = real(x)
if rx.dtype.char=='f':
c = 1e3*feps*amax(x)
c = 1e3*feps*amax(x)
else:
c = 1e3*eps*amax(x)
c = 1e3*eps*amax(x)
return sign( (absolute(rx) > c) * rx )
result,errest = funm(a, rounded_sign, disp=0)
errtol = {0:1e3*feps, 1:1e3*eps}[_array_precision[result.dtype.char]]
Expand Down
8 changes: 4 additions & 4 deletions scipy/linalg/tests/test_decomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def create_bandmat(self):

# symmetric band matrix
self.sym_mat = ( diag(1.0*ones(N))
+ diag(-1.0*ones(N-1), -1) + diag(-1.0*ones(N-1), 1)
+ diag(-1.0*ones(N-1), -1) + diag(-1.0*ones(N-1), 1)
+ diag(-2.0*ones(N-2), -2) + diag(-2.0*ones(N-2), 2) )

# hermitian band matrix
Expand All @@ -308,12 +308,12 @@ def create_bandmat(self):

# general real band matrix
self.real_mat = ( diag(1.0*ones(N))
+ diag(-1.0*ones(N-1), -1) + diag(-3.0*ones(N-1), 1)
+ diag(-1.0*ones(N-1), -1) + diag(-3.0*ones(N-1), 1)
+ diag(2.0*ones(N-2), -2) + diag(-2.0*ones(N-2), 2) )

# general complex band matrix
self.comp_mat = ( 1j*diag(1.0*ones(N))
+ diag(-1.0*ones(N-1), -1) + 1j*diag(-3.0*ones(N-1), 1)
+ diag(-1.0*ones(N-1), -1) + 1j*diag(-3.0*ones(N-1), 1)
+ diag(2.0*ones(N-2), -2) + diag(-2.0*ones(N-2), 2) )

# Eigenvalues and -vectors from linalg.eig
Expand Down Expand Up @@ -1778,7 +1778,7 @@ def test_qz_double_sort(self):
# [1.0, 3.0, -5.0, 4.0],
# [1.0, 3.0, -4.0, 3.0],
# [1.0, 3.0, -4.0, 4.0]])
A = np.array([[3.9, 12.5, -34.5, 2.5],
A = np.array([[3.9, 12.5, -34.5, 2.5],
[ 4.3, 21.5, -47.5, 7.5],
[ 4.3, 1.5, -43.5, 3.5],
[ 4.4, 6.0, -46.0, 6.0 ]])
Expand Down
2 changes: 1 addition & 1 deletion scipy/optimize/tests/test_anneal.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUp(self):
first one is used since the second fails for the 'fast' schedule at
least.
"""
self.fun = (lambda x: np.cos(14.5 * x - 0.3) + (x + 0.2) * x,
self.fun = (lambda x: np.cos(14.5 * x - 0.3) + (x + 0.2) * x,
lambda x: np.cos(14.5 * x[0] - 0.3) +
(x[1] + 0.2) * x[1] + (x[0] + 0.2) * x[0])
self.x0 = (1.0, [1.0, 1.0])
Expand Down
10 changes: 5 additions & 5 deletions scipy/optimize/tests/test_tnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ def f45(self, x):

def g45(self, x):
dif = [0] * 5
dif[0] = - x[1] * x[2] * x[3] * x[4] / 120.0
dif[1] = - x[0] * x[2] * x[3] * x[4] / 120.0
dif[2] = - x[0] * x[1] * x[3] * x[4] / 120.0
dif[3] = - x[0] * x[1] * x[2] * x[4] / 120.0
dif[4] = - x[0] * x[1] * x[2] * x[3] / 120.0
dif[0] = - x[1] * x[2] * x[3] * x[4] / 120.0
dif[1] = - x[0] * x[2] * x[3] * x[4] / 120.0
dif[2] = - x[0] * x[1] * x[3] * x[4] / 120.0
dif[3] = - x[0] * x[1] * x[2] * x[4] / 120.0
dif[4] = - x[0] * x[1] * x[2] * x[3] / 120.0
return dif

def fg45(self, x):
Expand Down
16 changes: 8 additions & 8 deletions scipy/optimize/tnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
}

INFEASIBLE = -1 # Infeasible (low > up)
LOCALMINIMUM = 0 # Local minima reach (|pg| ~= 0)
FCONVERGED = 1 # Converged (|f_n-f_(n-1)| ~= 0)
XCONVERGED = 2 # Converged (|x_n-x_(n-1)| ~= 0)
MAXFUN = 3 # Max. number of function evaluations reach
LSFAIL = 4 # Linear search failed
CONSTANT = 5 # All lower bounds are equal to the upper bounds
NOPROGRESS = 6 # Unable to progress
USERABORT = 7 # User requested end of minimization
LOCALMINIMUM = 0 # Local minima reach (|pg| ~= 0)
FCONVERGED = 1 # Converged (|f_n-f_(n-1)| ~= 0)
XCONVERGED = 2 # Converged (|x_n-x_(n-1)| ~= 0)
MAXFUN = 3 # Max. number of function evaluations reach
LSFAIL = 4 # Linear search failed
CONSTANT = 5 # All lower bounds are equal to the upper bounds
NOPROGRESS = 6 # Unable to progress
USERABORT = 7 # User requested end of minimization

RCSTRINGS = {
INFEASIBLE : "Infeasible (low > up)",
Expand Down
2 changes: 1 addition & 1 deletion scipy/sparse/benchmarks/bench_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def poisson2d(N,dtype='d',format=None):

diags = empty((5,N**2),dtype=dtype)

diags[0] = 4 # main diagonal
diags[0] = 4 # main diagonal
diags[1:] = -1 # all offdiagonals

diags[3,N-1::N] = 0 # first lower diagonal
Expand Down
2 changes: 1 addition & 1 deletion scipy/sparse/csr.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def check_bounds( i0, i1, num ):
self.indptr, self.indices, self.data,
int(i0), int(i1), int(j0), int(j1) )

shape = (i1 - i0, j1 - j0)
shape = (i1 - i0, j1 - j0)

return self.__class__( (data,indices,indptr), shape=shape )

Expand Down
2 changes: 1 addition & 1 deletion scipy/sparse/dia.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def __repr__(self):
format = self.getformat()
return "<%dx%d sparse matrix of type '%s'\n" \
"\twith %d stored elements (%d diagonals) in %s format>" % \
( self.shape + (self.dtype.type, nnz, self.data.shape[0],
( self.shape + (self.dtype.type, nnz, self.data.shape[0],
_formats[format][1],) )

def getnnz(self):
Expand Down
6 changes: 3 additions & 3 deletions scipy/sparse/linalg/dsolve/tests/test_linsolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_bvector_smoketest(self):
Adense = matrix([[ 0., 1., 1.],
[ 1., 0., 1.],
[ 0., 0., 1.]])
As = csc_matrix(Adense)
As = csc_matrix(Adense)
random.seed(1234)
x = random.randn(3)
b = As*x
Expand All @@ -57,7 +57,7 @@ def test_bmatrix_smoketest(self):
Adense = matrix([[ 0., 1., 1.],
[ 1., 0., 1.],
[ 0., 0., 1.]])
As = csc_matrix(Adense)
As = csc_matrix(Adense)
random.seed(1234)
x = random.randn(3, 4)
Bdense = As.dot(x)
Expand Down Expand Up @@ -180,7 +180,7 @@ def test_lu_refcount(self):
import sys
rc = sys.getrefcount(lu)
for attr in ('perm_r', 'perm_c'):
perm = getattr(lu, attr)
perm = getattr(lu, attr)
assert_equal(sys.getrefcount(lu), rc + 1)
del perm
assert_equal(sys.getrefcount(lu), rc)
Expand Down
2 changes: 1 addition & 1 deletion scipy/sparse/linalg/eigen/lobpcg/lobpcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def lobpcg( A, X,
# Main iteration loop.
for iterationNumber in xrange( maxIterations ):
if verbosityLevel > 0:
print('iteration %d' % iterationNumber)
print('iteration %d' % iterationNumber)

aux = blockVectorBX * _lambda[np.newaxis,:]
blockVectorR = blockVectorAX - aux
Expand Down
2 changes: 1 addition & 1 deletion scipy/sparse/linalg/eigen/lobpcg/tests/large_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def sakurai(n):
A = sparse.eye( n, n )
d0 = array(r_[5,6*ones(n-2),5])
d1 = -4*ones(n)
d2 = ones(n)
d2 = ones(n)
B = sparse.spdiags([d2,d1,d0,d1,d2],[-2,-1,0,1,2],n,n)

k = arange(1,n+1)
Expand Down
4 changes: 2 additions & 2 deletions scipy/sparse/linalg/isolve/lsqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def lsqr(A, b, damp=0.0, atol=1e-8, btol=1e-8, conlim=1e8,
cs2 = gambar / gamma
sn2 = theta / gamma
z = rhs / gamma
xxnorm = xxnorm + z**2
xxnorm = xxnorm + z**2

# Test for convergence.
# First, estimate the condition of the matrix Abar,
Expand Down Expand Up @@ -429,7 +429,7 @@ def lsqr(A, b, damp=0.0, atol=1e-8, btol=1e-8, conlim=1e8,
test2 = arnorm / (anorm * rnorm)
test3 = 1 / acond
t1 = test1 / (1 + anorm * xnorm / bnorm)
rtol = btol + atol * anorm * xnorm / bnorm
rtol = btol + atol * anorm * xnorm / bnorm

# The following tests guard against extremely small values of
# atol, btol or ctol. (The user may have set any or all of
Expand Down
20 changes: 10 additions & 10 deletions scipy/sparse/linalg/isolve/minres.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ def minres(A, b, x0=None, shift=0.0, tol=1e-5, maxiter=None, xtype=None,
# [gbar k dbar k+1] [sn -cs][alfak betak+1].

oldeps = epsln
delta = cs * dbar + sn * alfa # delta1 = 0 deltak
gbar = sn * dbar - cs * alfa # gbar 1 = alfa1 gbar k
epsln = sn * beta # epsln2 = 0 epslnk+1
dbar = - cs * beta # dbar 2 = beta2 dbar k+1
delta = cs * dbar + sn * alfa # delta1 = 0 deltak
gbar = sn * dbar - cs * alfa # gbar 1 = alfa1 gbar k
epsln = sn * beta # epsln2 = 0 epslnk+1
dbar = - cs * beta # dbar 2 = beta2 dbar k+1
root = norm([gbar, dbar])
Arnorm = phibar * root

Expand All @@ -213,9 +213,9 @@ def minres(A, b, x0=None, shift=0.0, tol=1e-5, maxiter=None, xtype=None,
gmax = max(gmax, gamma)
gmin = min(gmin, gamma)
z = rhs1 / gamma
ynorm2 = z**2 + ynorm2
rhs1 = rhs2 - delta*z
rhs2 = - epsln*z
ynorm2 = z**2 + ynorm2
rhs1 = rhs2 - delta*z
rhs2 = - epsln*z

# Estimate various norms and test for convergence.

Expand All @@ -231,7 +231,7 @@ def minres(A, b, x0=None, shift=0.0, tol=1e-5, maxiter=None, xtype=None,
qrnorm = phibar
rnorm = qrnorm
test1 = rnorm / (Anorm*ynorm) # ||r|| / (||A|| ||x||)
test2 = root / Anorm # ||Ar|| / (||A|| ||r||)
test2 = root / Anorm # ||Ar|| / (||A|| ||r||)

# Estimate cond(A).
# In this version we look at the diagonals of R in the
Expand Down Expand Up @@ -268,7 +268,7 @@ def minres(A, b, x0=None, shift=0.0, tol=1e-5, maxiter=None, xtype=None,
if qrnorm <= 10*epsx : prnt = True
if qrnorm <= 10*epsr : prnt = True
if Acond <= 1e-2/eps : prnt = True
if istop != 0 : prnt = True
if istop != 0 : prnt = True

if show and prnt:
str1 = '%6g %12.5e %10.3e' % (itn, x[0], test1)
Expand All @@ -289,7 +289,7 @@ def minres(A, b, x0=None, shift=0.0, tol=1e-5, maxiter=None, xtype=None,
print(last + ' istop = %3g itn =%5g' % (istop,itn))
print(last + ' Anorm = %12.4e Acond = %12.4e' % (Anorm,Acond))
print(last + ' rnorm = %12.4e ynorm = %12.4e' % (rnorm,ynorm))
print(last + ' Arnorm = %12.4e' % (Arnorm,))
print(last + ' Arnorm = %12.4e' % (Arnorm,))
print(last + msg[istop+1])

if istop == 6:
Expand Down
4 changes: 2 additions & 2 deletions scipy/sparse/linalg/isolve/tests/test_iterative.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self):
# Symmetric and Positive Definite
N = 40
data = ones((3,N))
data[0,:] = 2
data[0,:] = 2
data[1,:] = -1
data[2,:] = -1
Poisson1D = spdiags(data, [0,-1,1], N, N, format='csr')
Expand Down Expand Up @@ -104,7 +104,7 @@ def __init__(self):
# cgs, qmr, and bicg fail to converge on this one
# -- algorithmic limitation apparently
data = ones((2,10))
data[0,:] = 2
data[0,:] = 2
data[1,:] = -1
A = spdiags( data, [0,-1], 10, 10, format='csr')
self.cases.append(Case("nonsymposdef", A,
Expand Down
4 changes: 2 additions & 2 deletions scipy/sparse/linalg/isolve/tests/test_lsmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def lsmrtest(m, n, damp):
r = b - Afun.matvec(x)
r2 = sqrt(norm(r)**2 + (damp*norm(x))**2)
print(' ')
str = 'normr (est.) %17.10e' %(normr )
str2 = 'normr (true) %17.10e' %(r2 )
str = 'normr (est.) %17.10e' %(normr )
str2 = 'normr (true) %17.10e' %(r2 )
print(str)
print(str2)
print(' ')
Expand Down
4 changes: 2 additions & 2 deletions scipy/sparse/linalg/isolve/tests/test_lsqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def test_basic():
print("Norms computed in %.2fs by LSQR" % (time() - tic))
print(" ||x|| %9.4e ||r|| %9.4e ||Ar|| %9.4e " %( chio, phio, psio))
print("Residual norms computed directly:")
print(" ||x|| %9.4e ||r|| %9.4e ||Ar|| %9.4e" % (norm(xo),
print(" ||x|| %9.4e ||r|| %9.4e ||Ar|| %9.4e" % (norm(xo),
norm(G*xo - b),
norm(G.T*(G*xo-b))))
print("Direct solution norms:")
print(" ||x|| %9.4e ||r|| %9.4e " % (norm(svx), norm(G*svx -b)))
print(" ||x|| %9.4e ||r|| %9.4e " % (norm(svx), norm(G*svx -b)))
print("")
print(" || x_{direct} - x_{LSQR}|| %9.4e " % norm(svx-xo))
print("")
2 changes: 1 addition & 1 deletion scipy/spatial/tests/test_qhull.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def barycentric_transform(tr, x):

if unit_cube:
# If in unit cube, no interior point should be marked out of hull
at_boundary = (centroids <= unit_cube_tol).any(axis=1)
at_boundary = (centroids <= unit_cube_tol).any(axis=1)
at_boundary |= (centroids >= 1 - unit_cube_tol).any(axis=1)

ok = (j != -1) | at_boundary
Expand Down
2 changes: 1 addition & 1 deletion scipy/special/orthogonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def js_roots(n, p1, q1, mu=0):
# so roots of Gn(p,q,x) are (roots of P^(p-q,q-1)_n + 1) / 2.0
g = _gam
# integral of weight over interval
mu0 = g(q)*g(p-q+1)/g(p+1)
mu0 = g(q)*g(p-q+1)/g(p+1)
val = gen_roots_and_weights(n,an_Js,sbn_Js,mu0)
if mu:
return val + [mu0]
Expand Down
2 changes: 1 addition & 1 deletion scipy/special/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ def test_mathieu_a(self):
pass

def test_mathieu_even_coef(self):
mc = special.mathieu_even_coef(2,5)
mc = special.mathieu_even_coef(2,5)
#Q not defined broken and cannot figure out proper reporting order

def test_mathieu_odd_coef(self):
Expand Down
2 changes: 1 addition & 1 deletion scipy/special/tests/test_mpmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def __init__(self, scipy_func, mpmath_func, arg_spec, name=None,
if not name or name == '<lambda>':
name = getattr(scipy_func, '__name__', None)
if not name or name == '<lambda>':
name = getattr(mpmath_func, '__name__', None)
name = getattr(mpmath_func, '__name__', None)
self.name = name

def check(self):
Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/_tukeylambda_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def tukeylambda_variance(lam):
v[neghalf_mask] = np.inf
if small.size > 0:
# Use the Pade approximation near lambda = 0.
v[small_mask] = _tukeylambda_var_p(small) / _tukeylambda_var_q(small)
v[small_mask] = _tukeylambda_var_p(small) / _tukeylambda_var_q(small)
if reg.size > 0:
v[reg_mask] = (2.0 / reg**2) * (1.0 / (1.0 + 2 * reg) -
beta(reg + 1, reg + 1))
Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4560,7 +4560,7 @@ class pareto_gen(rv_continuous):
def _pdf(self, x, b):
return b * x**(-b-1)
def _cdf(self, x, b):
return 1 - x**(-b)
return 1 - x**(-b)
def _ppf(self, q, b):
return pow(1-q, -1.0/b)
def _stats(self, b, moments='mv'):
Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/mstats_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def kendalltau_seasonal(x):
#
n_tot = x.count()
ties = count_tied_groups(x.compressed())
corr_ties = np.sum(v*k*(k-1) for (k,v) in iteritems(ties))
corr_ties = np.sum(v*k*(k-1) for (k,v) in iteritems(ties))
denom_tot = ma.sqrt(1.*n_tot*(n_tot-1)*(n_tot*(n_tot-1)-corr_ties))/2.
#
R = rankdata(x, axis=0, use_missing=True)
Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/tests/test_mstats_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class TestHMean(TestCase):
def test_1D(self):
a = (1,2,3,4)
actual= mstats.hmean(a)
desired = 4. / (1./1 + 1./2 + 1./3 + 1./4)
desired = 4. / (1./1 + 1./2 + 1./3 + 1./4)
assert_almost_equal(actual, desired, decimal=14)
desired1 = mstats.hmean(ma.array(a),axis=-1)
assert_almost_equal(actual, desired1, decimal=14)
Expand Down
Loading

0 comments on commit 9b1bf5b

Please sign in to comment.