Skip to content

Commit

Permalink
PEP8: Fix E225 missing whitespace around operator
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Apr 14, 2013
1 parent 9b1bf5b commit f611c76
Show file tree
Hide file tree
Showing 120 changed files with 962 additions and 962 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 @@ -879,7 +879,7 @@ def test_is_monotonic_tdist_linkage1(self):
def test_is_monotonic_tdist_linkage2(self):
"Tests is_monotonic(Z) on clustering generated by single linkage on tdist data set. Perturbing. Expecting False."
Z = linkage(_ytdist, 'single')
Z[2,2]=0.0
Z[2,2] = 0.0
self.assertTrue(is_monotonic(Z) == False)

def test_is_monotonic_iris_linkage(self):
Expand Down
4 changes: 2 additions & 2 deletions scipy/cluster/tests/test_vq.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
from scipy.cluster.vq import kmeans, kmeans2, py_vq, py_vq2, vq, ClusterError
try:
from scipy.cluster import _vq
TESTC=True
TESTC = True
except ImportError:
print("== Error while importing _vq, not testing C imp of vq ==")
TESTC=False
TESTC = False

#Optional:
# import modules that are located in the same directory as this file.
Expand Down
2 changes: 1 addition & 1 deletion scipy/cluster/vq.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ def _kmeans2(data, code, niter, nc, missing):
label = vq(data, code)[0]
# Update the code by computing centroids using the new code book
for j in range(nc):
mbs = np.where(label==j)
mbs = np.where(label == j)
if mbs[0].size > 0:
code[j] = np.mean(data[mbs], axis=0)
else:
Expand Down
12 changes: 6 additions & 6 deletions scipy/fftpack/benchmarks/bench_pseudo_diffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ def direct_diff(x,k=1,period=None):
if period is None:
period = 2*pi
w = fftfreq(n)*2j*pi/period*n
if k<0:
if k < 0:
w = 1 / w**k
w[0] = 0.0
else:
w = w**k
if n>2000:
if n > 2000:
w[250:n-250] = 0.0
return ifft(w*fx).real

Expand Down Expand Up @@ -74,7 +74,7 @@ def bench_random(self):
print('%6s' % size, end=' ')
sys.stdout.flush()
x = arange(size)*2*pi/size
if size<2000:
if size < 2000:
f = sin(x)*cos(4*x)+exp(sin(3*x))
else:
f = sin(x)*cos(4*x)
Expand Down Expand Up @@ -106,7 +106,7 @@ def bench_random(self):
print('%6s' % size, end=' ')
sys.stdout.flush()
x = arange(size)*2*pi/size
if size<2000:
if size < 2000:
f = sin(x)*cos(4*x)+exp(sin(3*x))
else:
f = sin(x)*cos(4*x)
Expand Down Expand Up @@ -137,7 +137,7 @@ def bench_random(self):
print('%6s' % size, end=' ')
sys.stdout.flush()
x = arange(size)*2*pi/size
if size<2000:
if size < 2000:
f = sin(x)*cos(4*x)+exp(sin(3*x))
else:
f = sin(x)*cos(4*x)
Expand Down Expand Up @@ -169,7 +169,7 @@ def bench_random(self):
sys.stdout.flush()
x = arange(size)*2*pi/size
a = 1
if size<2000:
if size < 2000:
f = sin(x)*cos(4*x)+exp(sin(3*x))
sf = sin(x+a)*cos(4*(x+a))+exp(sin(3*(x+a)))
else:
Expand Down
32 changes: 16 additions & 16 deletions scipy/fftpack/pseudo_diffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def diff(x,order=1,period=None, _cache=_cache):
"""
tmp = asarray(x)
if order==0:
if order == 0:
return tmp
if iscomplexobj(tmp):
return diff(tmp.real,order,period)+1j*diff(tmp.imag,order,period)
Expand All @@ -62,7 +62,7 @@ def diff(x,order=1,period=None, _cache=_cache):
n = len(x)
omega = _cache.get((n,order,c))
if omega is None:
if len(_cache)>20:
if len(_cache) > 20:
while _cache: _cache.popitem()
def kernel(k,order=order,c=c):
if k:
Expand Down Expand Up @@ -159,14 +159,14 @@ def itilbert(x,h,period=None, _cache=_cache):
"""
tmp = asarray(x)
if iscomplexobj(tmp):
return itilbert(tmp.real,h,period)+\
return itilbert(tmp.real,h,period) + \
1j*itilbert(tmp.imag,h,period)
if period is not None:
h = h*2*pi/period
n = len(x)
omega = _cache.get((n,h))
if omega is None:
if len(_cache)>20:
if len(_cache) > 20:
while _cache: _cache.popitem()
def kernel(k,h=h):
if k: return -tanh(h*k)
Expand Down Expand Up @@ -219,11 +219,11 @@ def hilbert(x, _cache=_cache):
n = len(x)
omega = _cache.get(n)
if omega is None:
if len(_cache)>20:
if len(_cache) > 20:
while _cache: _cache.popitem()
def kernel(k):
if k>0: return 1.0
elif k<0: return -1.0
if k > 0: return 1.0
elif k < 0: return -1.0
return 0.0
omega = convolve.init_convolution_kernel(n,kernel,d=1)
_cache[n] = omega
Expand Down Expand Up @@ -279,15 +279,15 @@ def cs_diff(x, a, b, period=None, _cache=_cache):
"""
tmp = asarray(x)
if iscomplexobj(tmp):
return cs_diff(tmp.real,a,b,period)+\
return cs_diff(tmp.real,a,b,period) + \
1j*cs_diff(tmp.imag,a,b,period)
if period is not None:
a = a*2*pi/period
b = b*2*pi/period
n = len(x)
omega = _cache.get((n,a,b))
if omega is None:
if len(_cache)>20:
if len(_cache) > 20:
while _cache: _cache.popitem()
def kernel(k,a=a,b=b):
if k: return -cosh(a*k)/sinh(b*k)
Expand Down Expand Up @@ -328,15 +328,15 @@ def sc_diff(x, a, b, period=None, _cache=_cache):
"""
tmp = asarray(x)
if iscomplexobj(tmp):
return sc_diff(tmp.real,a,b,period)+\
return sc_diff(tmp.real,a,b,period) + \
1j*sc_diff(tmp.imag,a,b,period)
if period is not None:
a = a*2*pi/period
b = b*2*pi/period
n = len(x)
omega = _cache.get((n,a,b))
if omega is None:
if len(_cache)>20:
if len(_cache) > 20:
while _cache: _cache.popitem()
def kernel(k,a=a,b=b):
if k: return sinh(a*k)/cosh(b*k)
Expand Down Expand Up @@ -376,15 +376,15 @@ def ss_diff(x, a, b, period=None, _cache=_cache):
"""
tmp = asarray(x)
if iscomplexobj(tmp):
return ss_diff(tmp.real,a,b,period)+\
return ss_diff(tmp.real,a,b,period) + \
1j*ss_diff(tmp.imag,a,b,period)
if period is not None:
a = a*2*pi/period
b = b*2*pi/period
n = len(x)
omega = _cache.get((n,a,b))
if omega is None:
if len(_cache)>20:
if len(_cache) > 20:
while _cache: _cache.popitem()
def kernel(k,a=a,b=b):
if k: return sinh(a*k)/sinh(b*k)
Expand Down Expand Up @@ -428,15 +428,15 @@ def cc_diff(x, a, b, period=None, _cache=_cache):
"""
tmp = asarray(x)
if iscomplexobj(tmp):
return cc_diff(tmp.real,a,b,period)+\
return cc_diff(tmp.real,a,b,period) + \
1j*cc_diff(tmp.imag,a,b,period)
if period is not None:
a = a*2*pi/period
b = b*2*pi/period
n = len(x)
omega = _cache.get((n,a,b))
if omega is None:
if len(_cache)>20:
if len(_cache) > 20:
while _cache: _cache.popitem()
def kernel(k,a=a,b=b):
return cosh(a*k)/cosh(b*k)
Expand Down Expand Up @@ -474,7 +474,7 @@ def shift(x, a, period=None, _cache=_cache):
n = len(x)
omega = _cache.get((n,a))
if omega is None:
if len(_cache)>20:
if len(_cache) > 20:
while _cache: _cache.popitem()
def kernel_real(k,a=a): return cos(a*k)
def kernel_imag(k,a=a): return sin(a*k)
Expand Down
12 changes: 6 additions & 6 deletions scipy/fftpack/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def direct_rdft(x):
y = dot(exp(i*w),x)
if i:
r[2*i-1] = y.real
if 2*i<n:
if 2*i < n:
r[2*i] = y.imag
else:
r[0] = y.real
Expand All @@ -103,9 +103,9 @@ def direct_irdft(x):
x1 = zeros(n,dtype=cdouble)
for i in range(n//2+1):
if i:
if 2*i<n:
x1[i] = x[2*i-1] + 1j* x[2*i]
x1[n-i] = x[2*i-1] - 1j* x[2*i]
if 2*i < n:
x1[i] = x[2*i-1] + 1j*x[2*i]
x1[n-i] = x[2*i-1] - 1j*x[2*i]
else:
x1[i] = x[2*i-1]
else:
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_djbfft(self):
def test_random_complex(self):
for size in [1,51,111,100,200,64,128,256,1024]:
x = random([size]).astype(self.cdt)
x = random([size]).astype(self.cdt) +1j*x
x = random([size]).astype(self.cdt) + 1j*x
y1 = ifft(fft(x))
y2 = fft(ifft(x))
self.assertTrue(y1.dtype == self.cdt,
Expand Down Expand Up @@ -315,7 +315,7 @@ def setUp(self):
def test_definition(self):
x1 = [1,2,3,4,1,2,3,4]
x1_1 = [1,2+3j,4+1j,2+3j,4,2-3j,4-1j,2-3j]
x2= [1,2,3,4,1,2,3,4,5]
x2 = [1,2,3,4,1,2,3,4,5]
x2_1 = [1,2+3j,4+1j,2+3j,4+5j,4-5j,2-3j,4-1j,2-3j]

def _test(x, xr):
Expand Down
62 changes: 31 additions & 31 deletions scipy/fftpack/tests/test_pseudo_diffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ def direct_diff(x,k=1,period=None):
if period is None:
period = 2*pi
w = fftfreq(n)*2j*pi/period*n
if k<0:
if k < 0:
w = 1 / w**k
w[0] = 0.0
else:
w = w**k
if n>2000:
if n > 2000:
w[250:n-250] = 0.0
return ifft(w*fx).real

Expand Down Expand Up @@ -122,10 +122,10 @@ def test_sin(self):
def test_expr(self):
for n in [64,77,100,128,256,512,1024,2048,4096,8192][:5]:
x = arange(n)*2*pi/n
f=sin(x)*cos(4*x)+exp(sin(3*x))
df=cos(x)*cos(4*x)-4*sin(x)*sin(4*x)+3*cos(3*x)*exp(sin(3*x))
ddf=-17*sin(x)*cos(4*x)-8*cos(x)*sin(4*x)\
-9*sin(3*x)*exp(sin(3*x))+9*cos(3*x)**2*exp(sin(3*x))
f = sin(x)*cos(4*x)+exp(sin(3*x))
df = cos(x)*cos(4*x)-4*sin(x)*sin(4*x)+3*cos(3*x)*exp(sin(3*x))
ddf = -17*sin(x)*cos(4*x)-8*cos(x)*sin(4*x)\
- 9*sin(3*x)*exp(sin(3*x))+9*cos(3*x)**2*exp(sin(3*x))
d1 = diff(f)
assert_array_almost_equal(d1,df)
assert_array_almost_equal(diff(df),ddf)
Expand All @@ -136,10 +136,10 @@ def test_expr(self):
def test_expr_large(self):
for n in [2048,4096]:
x = arange(n)*2*pi/n
f=sin(x)*cos(4*x)+exp(sin(3*x))
df=cos(x)*cos(4*x)-4*sin(x)*sin(4*x)+3*cos(3*x)*exp(sin(3*x))
ddf=-17*sin(x)*cos(4*x)-8*cos(x)*sin(4*x)\
-9*sin(3*x)*exp(sin(3*x))+9*cos(3*x)**2*exp(sin(3*x))
f = sin(x)*cos(4*x)+exp(sin(3*x))
df = cos(x)*cos(4*x)-4*sin(x)*sin(4*x)+3*cos(3*x)*exp(sin(3*x))
ddf = -17*sin(x)*cos(4*x)-8*cos(x)*sin(4*x)\
- 9*sin(3*x)*exp(sin(3*x))+9*cos(3*x)**2*exp(sin(3*x))
assert_array_almost_equal(diff(f),df)
assert_array_almost_equal(diff(df),ddf)
assert_array_almost_equal(diff(ddf,-1),df)
Expand All @@ -156,9 +156,9 @@ def test_int(self):
def test_random_even(self):
for k in [0,2,4,6]:
for n in [60,32,64,56,55]:
f=random((n,))
af=sum(f,axis=0)/n
f=f-af
f = random((n,))
af = sum(f,axis=0)/n
f = f-af
# zeroing Nyquist mode:
f = diff(diff(f,1),-1)
assert_almost_equal(sum(f,axis=0),0.0)
Expand All @@ -168,19 +168,19 @@ def test_random_even(self):
def test_random_odd(self):
for k in [0,1,2,3,4,5,6]:
for n in [33,65,55]:
f=random((n,))
af=sum(f,axis=0)/n
f=f-af
f = random((n,))
af = sum(f,axis=0)/n
f = f-af
assert_almost_equal(sum(f,axis=0),0.0)
assert_array_almost_equal(diff(diff(f,k),-k),f)
assert_array_almost_equal(diff(diff(f,-k),k),f)

def test_zero_nyquist(self):
for k in [0,1,2,3,4,5,6]:
for n in [32,33,64,56,55]:
f=random((n,))
af=sum(f,axis=0)/n
f=f-af
f = random((n,))
af = sum(f,axis=0)/n
f = f-af
# zeroing Nyquist mode:
f = diff(diff(f,1),-1)
assert_almost_equal(sum(f,axis=0),0.0)
Expand All @@ -205,18 +205,18 @@ def test_definition(self):
def test_random_even(self):
for h in [0.1,0.5,1,5.5,10]:
for n in [32,64,56]:
f=random((n,))
af=sum(f,axis=0)/n
f=f-af
f = random((n,))
af = sum(f,axis=0)/n
f = f-af
assert_almost_equal(sum(f,axis=0),0.0)
assert_array_almost_equal(direct_tilbert(direct_itilbert(f,h),h),f)

def test_random_odd(self):
for h in [0.1,0.5,1,5.5,10]:
for n in [33,65,55]:
f=random((n,))
af=sum(f,axis=0)/n
f=f-af
f = random((n,))
af = sum(f,axis=0)/n
f = f-af
assert_almost_equal(sum(f,axis=0),0.0)
assert_array_almost_equal(itilbert(tilbert(f,h),h),f)
assert_array_almost_equal(tilbert(itilbert(f,h),h),f)
Expand Down Expand Up @@ -259,18 +259,18 @@ def test_tilbert_relation(self):

def test_random_odd(self):
for n in [33,65,55]:
f=random((n,))
af=sum(f,axis=0)/n
f=f-af
f = random((n,))
af = sum(f,axis=0)/n
f = f-af
assert_almost_equal(sum(f,axis=0),0.0)
assert_array_almost_equal(ihilbert(hilbert(f)),f)
assert_array_almost_equal(hilbert(ihilbert(f)),f)

def test_random_even(self):
for n in [32,64,56]:
f=random((n,))
af=sum(f,axis=0)/n
f=f-af
f = random((n,))
af = sum(f,axis=0)/n
f = f-af
# zeroing Nyquist mode:
f = diff(diff(f,1),-1)
assert_almost_equal(sum(f,axis=0),0.0)
Expand Down
2 changes: 1 addition & 1 deletion scipy/integrate/quadpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def _quad(func,a,b,args,full_output,epsabs,epsrel,limit,points):
else:
return _quadpack._qagie(func,bound,infbounds,args,full_output,epsabs,epsrel,limit)
else:
if infbounds !=0:
if infbounds != 0:
raise ValueError("Infinity inputs cannot be used with break points.")
else:
nl = len(points)
Expand Down
Loading

0 comments on commit f611c76

Please sign in to comment.