Skip to content

Commit

Permalink
PEP8: Fix E202 whitespace before ')'
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Apr 19, 2013
1 parent 2180a74 commit 6e4ecd9
Show file tree
Hide file tree
Showing 73 changed files with 756 additions and 756 deletions.
2 changes: 1 addition & 1 deletion scipy/cluster/tests/test_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
[877, 295, 0, 754, 564, 138],
[255, 468, 754, 0, 219, 869],
[412, 268, 564, 219, 0, 669],
[996, 400, 138, 869, 669, 0 ]], dtype='double')
[996, 400, 138, 869, 669, 0]], dtype='double')

_ytdist = squareform(_tdist)

Expand Down
6 changes: 3 additions & 3 deletions scipy/interpolate/interpolate_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def atleast_1d_and_contiguous(ary, dtype=np.float64):
return np.atleast_1d(np.ascontiguousarray(ary, dtype) )
return np.atleast_1d(np.ascontiguousarray(ary, dtype))


def nearest(x, y, new_x):
Expand All @@ -30,9 +30,9 @@ def nearest(x, y, new_x):
Rounds each `new_x` to nearest `x` and returns the corresponding `y`.
"""
shifted_x = np.concatenate((np.array([x[0]-1]) , x[0:-1] ))
shifted_x = np.concatenate((np.array([x[0]-1]) , x[0:-1]))

midpoints_of_x = atleast_1d_and_contiguous(.5*(x + shifted_x) )
midpoints_of_x = atleast_1d_and_contiguous(.5*(x + shifted_x))
new_x = atleast_1d_and_contiguous(new_x)

TINY = 1e-10
Expand Down
2 changes: 1 addition & 1 deletion scipy/interpolate/rbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def euclidean_norm(x1, x2):
"""

def _euclidean_norm(self, x1, x2):
return sqrt(((x1 - x2)**2).sum(axis=0) )
return sqrt(((x1 - x2)**2).sum(axis=0))

def _h_multiquadric(self, r):
return sqrt((1.0/self.epsilon*r)**2 + 1)
Expand Down
2 changes: 1 addition & 1 deletion scipy/io/mmio.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def _write(self, stream, a, comment='', field=None, precision=None):

if field == self.FIELD_PATTERN:
IJV = vstack((coo.row, coo.col)).T
elif field in [self.FIELD_INTEGER, self.FIELD_REAL ]:
elif field in [self.FIELD_INTEGER, self.FIELD_REAL]:
IJV = vstack((coo.row, coo.col, coo.data)).T
elif field == self.FIELD_COMPLEX:
IJV = vstack((coo.row, coo.col, coo.data.real, coo.data.imag)).T
Expand Down
8 changes: 4 additions & 4 deletions scipy/io/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
NC_SHORT: ('h', 2),
NC_INT: ('i', 4),
NC_FLOAT: ('f', 4),
NC_DOUBLE: ('d', 8) }
NC_DOUBLE: ('d', 8)}

REVERSE = {('b', 1): NC_BYTE,
('B', 1): NC_CHAR,
Expand All @@ -75,7 +75,7 @@
# these come from asarray(1).dtype.char and asarray('foo').dtype.char,
# used when getting the types from generic attributes.
('l', 4): NC_INT,
('S', 1): NC_CHAR }
('S', 1): NC_CHAR}


class netcdf_file(object):
Expand Down Expand Up @@ -369,9 +369,9 @@ def _write_var_array(self):

# Sort variables non-recs first, then recs. We use a DSU
# since some people use pupynere with Python 2.3.x.
deco = [(v._shape and not v.isrec, k) for (k, v) in self.variables.items() ]
deco = [(v._shape and not v.isrec, k) for (k, v) in self.variables.items()]
deco.sort()
variables = [k for (unused, k) in deco ][::-1]
variables = [k for (unused, k) in deco][::-1]

# Set the metadata for all variables.
for name in variables:
Expand Down
8 changes: 4 additions & 4 deletions scipy/io/tests/test_mmio.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def test_empty_write_read(self):
def test_real_write_read(self):
I = array([0, 0, 1, 2, 3, 3, 3, 4])
J = array([0, 3, 1, 2, 1, 3, 4, 4])
V = array([1.0, 6.0, 10.5, 0.015, 250.5, -280.0, 33.32, 12.0 ])
V = array([1.0, 6.0, 10.5, 0.015, 250.5, -280.0, 33.32, 12.0])

b = scipy.sparse.coo_matrix((V,(I,J)),shape=(5,5))

Expand Down Expand Up @@ -311,12 +311,12 @@ def test_sparse_formats(self):
I = array([0, 0, 1, 2, 3, 3, 3, 4])
J = array([0, 3, 1, 2, 1, 3, 4, 4])

V = array([1.0, 6.0, 10.5, 0.015, 250.5, -280.0, 33.32, 12.0 ])
mats.append(scipy.sparse.coo_matrix((V,(I,J)),shape=(5,5)) )
V = array([1.0, 6.0, 10.5, 0.015, 250.5, -280.0, 33.32, 12.0])
mats.append(scipy.sparse.coo_matrix((V,(I,J)),shape=(5,5)))

V = array([1.0 + 3j, 6.0 + 2j, 10.50 + 0.9j, 0.015 + -4.4j,
250.5 + 0j, -280.0 + 5j, 33.32 + 6.4j, 12.00 + 0.8j])
mats.append(scipy.sparse.coo_matrix((V,(I,J)),shape=(5,5)) )
mats.append(scipy.sparse.coo_matrix((V,(I,J)),shape=(5,5)))

for mat in mats:
expected = mat.todense()
Expand Down
2 changes: 1 addition & 1 deletion scipy/linalg/matfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def rounded_sign(x):
c = 1e3*feps*amax(x)
else:
c = 1e3*eps*amax(x)
return sign((absolute(rx) > c) * rx )
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]]
if errest < errtol:
Expand Down
44 changes: 22 additions & 22 deletions scipy/linalg/tests/test_decomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def random_rot(dim):
For more information see
http://en.wikipedia.org/wiki/Orthogonal_matrix#Randomization"""
H = eye(dim)
D = ones((dim, ))
D = ones((dim,))
for n in range(1, dim):
x = normal(size=(dim-n+1, ))
x = normal(size=(dim-n+1,))
D[n-1] = sign(x[0])
x[0] -= D[n-1]*sqrt((x*x).sum())
# Householder transformation
Expand Down Expand Up @@ -309,22 +309,22 @@ 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(-2.0*ones(N-2), -2) + diag(-2.0*ones(N-2), 2) )
+ diag(-2.0*ones(N-2), -2) + diag(-2.0*ones(N-2), 2))

# hermitian band matrix
self.herm_mat = (diag(-1.0*ones(N))
+ 1j*diag(1.0*ones(N-1), -1) - 1j*diag(1.0*ones(N-1), 1)
+ diag(-2.0*ones(N-2), -2) + diag(-2.0*ones(N-2), 2) )
+ diag(-2.0*ones(N-2), -2) + diag(-2.0*ones(N-2), 2))

# 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(2.0*ones(N-2), -2) + diag(-2.0*ones(N-2), 2) )
+ 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(2.0*ones(N-2), -2) + diag(-2.0*ones(N-2), 2) )
+ diag(2.0*ones(N-2), -2) + diag(-2.0*ones(N-2), 2))

# Eigenvalues and -vectors from linalg.eig
ew, ev = linalg.eig(self.sym_mat)
Expand Down Expand Up @@ -434,26 +434,26 @@ def test_eigvals_banded(self):
ind1 = 2
ind2 = 6
w_sym_ind = eigvals_banded(self.bandmat_sym,
select='i', select_range=(ind1, ind2) )
select='i', select_range=(ind1, ind2))
assert_array_almost_equal(sort(w_sym_ind),
self.w_sym_lin[ind1:ind2+1])
w_herm_ind = eigvals_banded(self.bandmat_herm,
select='i', select_range=(ind1, ind2) )
select='i', select_range=(ind1, ind2))
assert_array_almost_equal(sort(w_herm_ind),
self.w_herm_lin[ind1:ind2+1])

# extracting eigenvalues with respect to a value range
v_lower = self.w_sym_lin[ind1] - 1.0e-5
v_upper = self.w_sym_lin[ind2] + 1.0e-5
w_sym_val = eigvals_banded(self.bandmat_sym,
select='v', select_range=(v_lower, v_upper) )
select='v', select_range=(v_lower, v_upper))
assert_array_almost_equal(sort(w_sym_val),
self.w_sym_lin[ind1:ind2+1])

v_lower = self.w_herm_lin[ind1] - 1.0e-5
v_upper = self.w_herm_lin[ind2] + 1.0e-5
w_herm_val = eigvals_banded(self.bandmat_herm,
select='v', select_range=(v_lower, v_upper) )
select='v', select_range=(v_lower, v_upper))
assert_array_almost_equal(sort(w_herm_val),
self.w_herm_lin[ind1:ind2+1])

Expand All @@ -478,37 +478,37 @@ def test_eig_banded(self):
ind1 = 2
ind2 = 6
w_sym_ind, evec_sym_ind = eig_banded(self.bandmat_sym,
select='i', select_range=(ind1, ind2) )
select='i', select_range=(ind1, ind2))
assert_array_almost_equal(sort(w_sym_ind),
self.w_sym_lin[ind1:ind2+1])
assert_array_almost_equal(abs(evec_sym_ind),
abs(self.evec_sym_lin[:,ind1:ind2+1]) )
abs(self.evec_sym_lin[:,ind1:ind2+1]))

w_herm_ind, evec_herm_ind = eig_banded(self.bandmat_herm,
select='i', select_range=(ind1, ind2) )
select='i', select_range=(ind1, ind2))
assert_array_almost_equal(sort(w_herm_ind),
self.w_herm_lin[ind1:ind2+1])
assert_array_almost_equal(abs(evec_herm_ind),
abs(self.evec_herm_lin[:,ind1:ind2+1]) )
abs(self.evec_herm_lin[:,ind1:ind2+1]))

# extracting eigenvalues with respect to a value range
v_lower = self.w_sym_lin[ind1] - 1.0e-5
v_upper = self.w_sym_lin[ind2] + 1.0e-5
w_sym_val, evec_sym_val = eig_banded(self.bandmat_sym,
select='v', select_range=(v_lower, v_upper) )
select='v', select_range=(v_lower, v_upper))
assert_array_almost_equal(sort(w_sym_val),
self.w_sym_lin[ind1:ind2+1])
assert_array_almost_equal(abs(evec_sym_val),
abs(self.evec_sym_lin[:,ind1:ind2+1]) )
abs(self.evec_sym_lin[:,ind1:ind2+1]))

v_lower = self.w_herm_lin[ind1] - 1.0e-5
v_upper = self.w_herm_lin[ind2] + 1.0e-5
w_herm_val, evec_herm_val = eig_banded(self.bandmat_herm,
select='v', select_range=(v_lower, v_upper) )
select='v', select_range=(v_lower, v_upper))
assert_array_almost_equal(sort(w_herm_val),
self.w_herm_lin[ind1:ind2+1])
assert_array_almost_equal(abs(evec_herm_val),
abs(self.evec_herm_lin[:,ind1:ind2+1]) )
abs(self.evec_herm_lin[:,ind1:ind2+1]))

w_sym, evec_sym = eig_banded(self.bandmat_sym, check_finite=False)
evec_sym_ = evec_sym[:,argsort(w_sym.real)]
Expand Down Expand Up @@ -566,7 +566,7 @@ def test_zgbtrs(self):

def test_eigh():
DIM = 6
v = {'dim': (DIM, ),
v = {'dim': (DIM,),
'dtype': ('f','d','F','D'),
'overwrite': (True, False),
'lower': (True, False),
Expand Down Expand Up @@ -1810,7 +1810,7 @@ def test_qz_double_sort(self):
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 ]])
[4.4, 6.0, -46.0, 6.0]])

B = np.array([[1.0, 1.0, -3.0, 1.0],
[1.0, 3.0, -5.0, 4.4],
Expand All @@ -1830,15 +1830,15 @@ def test_qz_double_sort(self):
# test absolute values bc the sign is ambiguous and might be platform
# dependent
assert_array_almost_equal(np.abs(AA), np.abs(np.array(
[[35.7864, -80.9061, -12.0629, -9.498 ],
[[35.7864, -80.9061, -12.0629, -9.498],
[0. , 2.7638, -2.3505, 7.3256],
[0. , 0. , 0.6258, -0.0398],
[0. , 0. , 0. , -12.8217]])), 4)
assert_array_almost_equal(np.abs(BB), np.abs(np.array(
[[4.5324, -8.7878, 3.2357, -3.5526],
[0. , 1.4314, -2.1894, 0.9709],
[0. , 0. , 1.3126, -0.3468],
[0. , 0. , 0. , 0.559 ]])), 4)
[0. , 0. , 0. , 0.559]])), 4)
assert_array_almost_equal(np.abs(Q), np.abs(np.array(
[[-0.4193, -0.605 , -0.1894, -0.6498],
[-0.5495, 0.6987, 0.2654, -0.3734],
Expand Down
10 changes: 5 additions & 5 deletions scipy/linalg/tests/test_matfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
class TestSignM(TestCase):

def test_nils(self):
a = array([[29.2, -24.2, 69.5, 49.8, 7. ],
[-9.2, 5.2, -18. , -16.8, -2. ],
[-10. , 6. , -20. , -18. , -2. ],
[-9.6, 9.6, -25.5, -15.4, -2. ],
[9.8, -4.8, 18. , 18.2, 2. ]])
a = array([[29.2, -24.2, 69.5, 49.8, 7.],
[-9.2, 5.2, -18. , -16.8, -2.],
[-10. , 6. , -20. , -18. , -2.],
[-9.6, 9.6, -25.5, -15.4, -2.],
[9.8, -4.8, 18. , 18.2, 2.]])
cr = array([[11.94933333,-2.24533333,15.31733333,21.65333333,-2.24533333],
[-3.84266667,0.49866667,-4.59066667,-7.18666667,0.49866667],
[-4.08,0.56,-4.92,-7.6 ,0.56],
Expand Down
8 changes: 4 additions & 4 deletions scipy/linalg/tests/test_special_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ def test_basic(self):
m1 = array([[1, 2], [3, 4]])
m2 = array([[10], [11]])
a = kron(m1, m2)
expected = array([[10, 20 ],
[11, 22 ],
[30, 40 ],
[33, 44 ]])
expected = array([[10, 20],
[11, 22],
[30, 40],
[33, 44]])
assert_array_equal(a, expected)


Expand Down
2 changes: 1 addition & 1 deletion scipy/ndimage/tests/test_ndimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def test_correlate15(self):

def test_correlate16(self):
"correlation 16"
kernel = numpy.array([[0.5, 0 ],
kernel = numpy.array([[0.5, 0],
[0, 0.5]])
for type1 in self.types:
array = numpy.array([[1, 2, 3],
Expand Down
4 changes: 2 additions & 2 deletions scipy/odr/tests/test_odr.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def test_multi(self):
assert_array_almost_equal(
out.cov_beta,
np.array([[0.0064918418231375, 0.0036159705923791, 0.0438637051470406,
-0.0058700836512467, 0.011281212888768 ],
-0.0058700836512467, 0.011281212888768],
[0.0036159705923791, 0.0064793789429006, 0.0517610978353126,
-0.0051181304940204, 0.0130726943624117],
[0.0438637051470406, 0.0517610978353126, 0.5182263323095322,
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_pearson(self):
assert_array_almost_equal(
out.cov_beta,
np.array([[0.0854275622946333, -0.0161807025443155],
[-0.0161807025443155, 0.003306337993922 ]]),
[-0.0161807025443155, 0.003306337993922]]),
)

rout = pr_odr.run()
Expand Down
4 changes: 2 additions & 2 deletions scipy/optimize/slsqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def approx_jacobian(x,func,epsilon,*args):
def fmin_slsqp(func, x0 , eqcons=[], f_eqcons=None, ieqcons=[], f_ieqcons=None,
bounds=[], fprime=None, fprime_eqcons=None,
fprime_ieqcons=None, args=(), iter = 100, acc = 1.0E-6,
iprint = 1, disp = None, full_output = 0, epsilon = _epsilon ):
iprint = 1, disp = None, full_output = 0, epsilon = _epsilon):
"""
Minimize a function using Sequential Least SQuares Programming
Expand Down Expand Up @@ -281,7 +281,7 @@ def cjac(x, *args):
6 : "Singular matrix C in LSQ subproblem",
7 : "Rank-deficient equality constraint subproblem HFTI",
8 : "Positive directional derivative for linesearch",
9 : "Iteration limit exceeded" }
9 : "Iteration limit exceeded"}

# Wrap func
feval, func = wrap_function(func, args)
Expand Down
2 changes: 1 addition & 1 deletion scipy/optimize/tests/test_nonlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def F5(x):

def F6(x):
x1, x2 = x
J0 = np.array([[-4.256 , 14.7 ],
J0 = np.array([[-4.256 , 14.7],
[0.8394989 , 0.59964207]])
v = np.array([(x1 + 3) * (x2**5 - 7) + 3*6,
np.sin(x2 * np.exp(x1) - 1)])
Expand Down
2 changes: 1 addition & 1 deletion scipy/signal/cont2discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def cont2discrete(sys, dt, method="zoh", alpha=None):

# Need to stack zeros under the a and b matrices
em_lower = np.hstack((np.zeros((b.shape[1], a.shape[0])),
np.zeros((b.shape[1], b.shape[1])) ))
np.zeros((b.shape[1], b.shape[1]))))

em = np.vstack((em_upper, em_lower))
ms = linalg.expm(dt * em)
Expand Down
4 changes: 2 additions & 2 deletions scipy/signal/tests/test_fir_filter_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def test_hilbert(self):
a = 0.1 # width of the transition band

# design an unity gain hilbert bandpass filter from w to 0.5-w
h = remez(11, [a, 0.5-a ], [1 ], type='hilbert')
h = remez(11, [a, 0.5-a], [1], type='hilbert')

# make sure the filter has correct # of taps
assert_(len(h) == N, "Number of Taps")
Expand All @@ -383,7 +383,7 @@ def test_hilbert(self):
Hmag = abs(H)

# should have a zero at 0 and pi (in this case close to zero)
assert_((Hmag[[0,-1] ] < 0.02).all(), "Zero at zero and pi")
assert_((Hmag[[0,-1]] < 0.02).all(), "Zero at zero and pi")

# check that the pass band is close to unity
idx = (f > a) * (f < 0.5-a)
Expand Down
2 changes: 1 addition & 1 deletion scipy/signal/tests/test_signaltools.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ def test_hilbert_axisN(self):
0.000000000000000e+00-0.332049855010597j,
3.552713678800501e-16-0.403810179797771j,
8.881784197001253e-17-0.751023775297729j,
9.444121133484362e-17-0.79252210110103j ])
9.444121133484362e-17-0.79252210110103j])
yield assert_almost_equal, aan[0], a0hilb, 14, 'N regression'


Expand Down
Loading

0 comments on commit 6e4ecd9

Please sign in to comment.