Skip to content

Commit

Permalink
PEP8: Fix E261 at least two spaces before inline comment
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Apr 21, 2013
1 parent d3a14f6 commit 6f9f01d
Show file tree
Hide file tree
Showing 125 changed files with 910 additions and 910 deletions.
36 changes: 18 additions & 18 deletions scipy/cluster/vq.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,9 @@ def py_vq2(obs, code_book):
diff = obs[newaxis, :, :] - code_book[:,newaxis,:]
dist = sqrt(np.sum(diff * diff, -1))
code = argmin(dist, 0)
min_dist = minimum.reduce(dist, 0) # the next line I think is equivalent
min_dist = minimum.reduce(dist, 0) # the next line I think is equivalent
# - and should be faster
#min_dist = choose(code,dist) # but in practice, didn't seem to make
# min_dist = choose(code,dist) # but in practice, didn't seem to make
# much difference.
return code, min_dist

Expand Down Expand Up @@ -391,22 +391,22 @@ def _kmeans(obs, guess, thresh=1e-5):
diff = thresh+1.
while diff > thresh:
nc = code_book.shape[0]
#compute membership and distances between obs and code_book
# compute membership and distances between obs and code_book
obs_code, distort = vq(obs, code_book)
avg_dist.append(mean(distort, axis=-1))
#recalc code_book as centroids of associated obs
# recalc code_book as centroids of associated obs
if(diff > thresh):
has_members = []
for i in arange(nc):
cell_members = compress(equal(obs_code, i), obs, 0)
if cell_members.shape[0] > 0:
code_book[i] = mean(cell_members, 0)
has_members.append(i)
#remove code_books that didn't have any members
# remove code_books that didn't have any members
code_book = take(code_book, has_members, 0)
if len(avg_dist) > 1:
diff = avg_dist[-2] - avg_dist[-1]
#print avg_dist
# print avg_dist
return code_book, avg_dist[-1]


Expand Down Expand Up @@ -508,14 +508,14 @@ def kmeans(obs, k_or_guess, iter=20, thresh=1e-5):
guess)
result = _kmeans(obs, guess, thresh=thresh)
else:
#initialize best distance value to a large value
# initialize best distance value to a large value
best_dist = np.inf
No = obs.shape[0]
k = k_or_guess
if k < 1:
raise ValueError("Asked for 0 cluster ? ")
for i in range(iter):
#the intial code book is randomly selected from observations
# the intial code book is randomly selected from observations
guess = take(obs, randint(0, No, k), 0)
book, dist = _kmeans(obs, guess, thresh=thresh)
if dist < best_dist:
Expand Down Expand Up @@ -666,7 +666,7 @@ def kmeans2(data, k, iter=10, thresh=1e-5, minit='random',
nd = np.ndim(data)
if nd == 1:
d = 1
#raise ValueError("Input of rank 1 not supported yet")
# raise ValueError("Input of rank 1 not supported yet")
elif nd == 2:
d = data.shape[1]
else:
Expand Down Expand Up @@ -733,14 +733,14 @@ def _kmeans2(data, code, niter, nc, missing):

if __name__ == '__main__':
pass
#import _vq
#a = np.random.randn(4, 2)
#b = np.random.randn(2, 2)
# import _vq
# a = np.random.randn(4, 2)
# b = np.random.randn(2, 2)

#print _vq.vq(a, b)
#print _vq.vq(np.array([[1], [2], [3], [4], [5], [6.]]),
# print _vq.vq(a, b)
# print _vq.vq(np.array([[1], [2], [3], [4], [5], [6.]]),
# np.array([[2.], [5.]]))
#print _vq.vq(np.array([1, 2, 3, 4, 5, 6.]), np.array([2., 5.]))
#_vq.vq(a.astype(np.float32), b.astype(np.float32))
#_vq.vq(a, b.astype(np.float32))
#_vq.vq([0], b)
# print _vq.vq(np.array([1, 2, 3, 4, 5, 6.]), np.array([2., 5.]))
# _vq.vq(a.astype(np.float32), b.astype(np.float32))
# _vq.vq(a, b.astype(np.float32))
# _vq.vq([0], b)
2 changes: 1 addition & 1 deletion scipy/constants/codata.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ def find(sub=None, disp=False):
'mag. constant': (mu0, 'N A^-2', 0.0),
'electric constant': (epsilon0, 'F m^-1', 0.0),
'characteristic impedance of vacuum': (sqrt(mu0/epsilon0), 'ohm', 0.0),
'atomic unit of permittivity': (4*epsilon0*pi, 'F m^-1', 0.0), # is that the definition?
'atomic unit of permittivity': (4*epsilon0*pi, 'F m^-1', 0.0), # is that the definition?
'joule-kilogram relationship': (1/(c*c), 'kg', 0.0),
'kilogram-joule relationship': (c*c, 'J', 0.0),
'hertz-inverse meter relationship': (1/c, 'm^-1', 0.0)
Expand Down
60 changes: 30 additions & 30 deletions scipy/constants/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
from .codata import value as _cd
import numpy as _np

#mathematical constants
# mathematical constants
pi = _math.pi
golden = golden_ratio = (1 + _math.sqrt(5)) / 2

#SI prefixes
# SI prefixes
yotta = 1e24
zetta = 1e21
exa = 1e18
Expand All @@ -46,7 +46,7 @@
atto = 1e-18
zepto = 1e-21

#binary prefixes
# binary prefixes
kibi = 2**10
mebi = 2**20
gibi = 2**30
Expand All @@ -56,7 +56,7 @@
zebi = 2**70
yobi = 2**80

#physical constants
# physical constants
c = speed_of_light = _cd('speed of light in vacuum')
mu_0 = 4e-7*pi
epsilon_0 = 1 / (mu_0*c*c)
Expand All @@ -73,17 +73,17 @@
Wien = _cd('Wien wavelength displacement law constant')
Rydberg = _cd('Rydberg constant')

#weight in kg
# weight in kg
gram = 1e-3
metric_ton = 1e3
grain = 64.79891e-6
lb = pound = 7000 * grain # avoirdupois
lb = pound = 7000 * grain # avoirdupois
oz = ounce = pound / 16
stone = 14 * pound
long_ton = 2240 * pound
short_ton = 2000 * pound

troy_ounce = 480 * grain # only for metals / gems
troy_ounce = 480 * grain # only for metals / gems
troy_pound = 12 * troy_ounce
carat = 200e-6

Expand All @@ -92,26 +92,26 @@
m_n = neutron_mass = _cd('neutron mass')
m_u = u = atomic_mass = _cd('atomic mass constant')

#angle in rad
# angle in rad
degree = pi / 180
arcmin = arcminute = degree / 60
arcsec = arcsecond = arcmin / 60

#time in second
# time in second
minute = 60.0
hour = 60 * minute
day = 24 * hour
week = 7 * day
year = 365 * day
Julian_year = 365.25 * day

#length in meter
# length in meter
inch = 0.0254
foot = 12 * inch
yard = 3 * foot
mile = 1760 * yard
mil = inch / 1000
pt = point = inch / 72 # typography
pt = point = inch / 72 # typography
survey_foot = 1200.0 / 3937
survey_mile = 5280 * survey_foot
nautical_mile = 1852.0
Expand All @@ -122,55 +122,55 @@
light_year = Julian_year * c
parsec = au / arcsec

#pressure in pascal
# pressure in pascal
atm = atmosphere = _cd('standard atmosphere')
bar = 1e5
torr = mmHg = atm / 760
psi = pound * g / (inch * inch)

#area in meter**2
# area in meter**2
hectare = 1e4
acre = 43560 * foot**2

#volume in meter**3
# volume in meter**3
litre = liter = 1e-3
gallon = gallon_US = 231 * inch**3 # US
#pint = gallon_US / 8
gallon = gallon_US = 231 * inch**3 # US
# pint = gallon_US / 8
fluid_ounce = fluid_ounce_US = gallon_US / 128
bbl = barrel = 42 * gallon_US # for oil
bbl = barrel = 42 * gallon_US # for oil

gallon_imp = 4.54609e-3 # uk
gallon_imp = 4.54609e-3 # uk
fluid_ounce_imp = gallon_imp / 160

#speed in meter per second
# speed in meter per second
kmh = 1e3 / hour
mph = mile / hour
mach = speed_of_sound = 340.5 # approx value at 15 degrees in 1 atm. is this a common value?
mach = speed_of_sound = 340.5 # approx value at 15 degrees in 1 atm. is this a common value?
knot = nautical_mile / hour

#temperature in kelvin
# temperature in kelvin
zero_Celsius = 273.15
degree_Fahrenheit = 1/1.8 # only for differences
degree_Fahrenheit = 1/1.8 # only for differences

#energy in joule
eV = electron_volt = elementary_charge # * 1 Volt
# energy in joule
eV = electron_volt = elementary_charge # * 1 Volt
calorie = calorie_th = 4.184
calorie_IT = 4.1868
erg = 1e-7
Btu_th = pound * degree_Fahrenheit * calorie_th / gram
Btu = Btu_IT = pound * degree_Fahrenheit * calorie_IT / gram
ton_TNT = 1e9 * calorie_th
#Wh = watt_hour
# Wh = watt_hour

#power in watt
# power in watt
hp = horsepower = 550 * foot * pound * g

#force in newton
# force in newton
dyn = dyne = 1e-5
lbf = pound_force = pound * g
kgf = kilogram_force = g # * 1 kg
kgf = kilogram_force = g # * 1 kg

#functions for conversions that are not linear
# functions for conversions that are not linear


def C2K(C):
Expand Down Expand Up @@ -346,7 +346,7 @@ def K2F(K):
"""
return C2F(K2C(_np.asanyarray(K)))

#optics
# optics


def lambda2nu(lambda_):
Expand Down
44 changes: 22 additions & 22 deletions scipy/fftpack/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def test_definition(self):
assert_array_almost_equal(fftn(x),direct_dftn(x))

def test_axes_argument(self):
#plane == ji_plane, x== kji_space
# plane == ji_plane, x== kji_space
plane1 = [[1,2,3],[4,5,6],[7,8,9]]
plane2 = [[10,11,12],[13,14,15],[16,17,18]]
plane3 = [[19,20,21],[22,23,24],[25,26,27]]
Expand All @@ -499,67 +499,67 @@ def test_axes_argument(self):
kij_space = [ij_plane1,ij_plane2,ij_plane3]
x = array([plane1,plane2,plane3])

assert_array_almost_equal(fftn(x),fftn(x,axes=(-3,-2,-1))) # kji_space
assert_array_almost_equal(fftn(x),fftn(x,axes=(-3,-2,-1))) # kji_space
assert_array_almost_equal(fftn(x),fftn(x,axes=(0,1,2)))
y = fftn(x,axes=(2,1,0)) # ijk_space
y = fftn(x,axes=(2,1,0)) # ijk_space
assert_array_almost_equal(swapaxes(y,-1,-3),fftn(ijk_space))
y = fftn(x,axes=(2,0,1)) # ikj_space
y = fftn(x,axes=(2,0,1)) # ikj_space
assert_array_almost_equal(swapaxes(swapaxes(y,-1,-3),
-1,-2),
fftn(ikj_space))
y = fftn(x,axes=(1,2,0)) # jik_space
y = fftn(x,axes=(1,2,0)) # jik_space
assert_array_almost_equal(swapaxes(swapaxes(y,-1,-3),
-3,-2),
fftn(jik_space))
y = fftn(x,axes=(1,0,2)) # jki_space
y = fftn(x,axes=(1,0,2)) # jki_space
assert_array_almost_equal(swapaxes(y,-2,-3),fftn(jki_space))
y = fftn(x,axes=(0,2,1)) # kij_space
y = fftn(x,axes=(0,2,1)) # kij_space
assert_array_almost_equal(swapaxes(y,-2,-1),
fftn(kij_space))

y = fftn(x,axes=(-2,-1)) # ji_plane
y = fftn(x,axes=(-2,-1)) # ji_plane
assert_array_almost_equal(fftn(plane1),y[0])
assert_array_almost_equal(fftn(plane2),y[1])
assert_array_almost_equal(fftn(plane3),y[2])
y = fftn(x,axes=(1,2)) # ji_plane
y = fftn(x,axes=(1,2)) # ji_plane
assert_array_almost_equal(fftn(plane1),y[0])
assert_array_almost_equal(fftn(plane2),y[1])
assert_array_almost_equal(fftn(plane3),y[2])
y = fftn(x,axes=(-3,-2)) # kj_plane
y = fftn(x,axes=(-3,-2)) # kj_plane
assert_array_almost_equal(fftn(x[:,:,0]),y[:,:,0])
assert_array_almost_equal(fftn(x[:,:,1]),y[:,:,1])
assert_array_almost_equal(fftn(x[:,:,2]),y[:,:,2])
y = fftn(x,axes=(-3,-1)) # ki_plane
y = fftn(x,axes=(-3,-1)) # ki_plane
assert_array_almost_equal(fftn(x[:,0,:]),y[:,0,:])
assert_array_almost_equal(fftn(x[:,1,:]),y[:,1,:])
assert_array_almost_equal(fftn(x[:,2,:]),y[:,2,:])
y = fftn(x,axes=(-1,-2)) # ij_plane
y = fftn(x,axes=(-1,-2)) # ij_plane
assert_array_almost_equal(fftn(ij_plane1),swapaxes(y[0],-2,-1))
assert_array_almost_equal(fftn(ij_plane2),swapaxes(y[1],-2,-1))
assert_array_almost_equal(fftn(ij_plane3),swapaxes(y[2],-2,-1))
y = fftn(x,axes=(-1,-3)) # ik_plane
y = fftn(x,axes=(-1,-3)) # ik_plane
assert_array_almost_equal(fftn(ik_plane1),swapaxes(y[:,0,:],-1,-2))
assert_array_almost_equal(fftn(ik_plane2),swapaxes(y[:,1,:],-1,-2))
assert_array_almost_equal(fftn(ik_plane3),swapaxes(y[:,2,:],-1,-2))
y = fftn(x,axes=(-2,-3)) # jk_plane
y = fftn(x,axes=(-2,-3)) # jk_plane
assert_array_almost_equal(fftn(jk_plane1),swapaxes(y[:,:,0],-1,-2))
assert_array_almost_equal(fftn(jk_plane2),swapaxes(y[:,:,1],-1,-2))
assert_array_almost_equal(fftn(jk_plane3),swapaxes(y[:,:,2],-1,-2))

y = fftn(x,axes=(-1,)) # i_line
y = fftn(x,axes=(-1,)) # i_line
for i in range(3):
for j in range(3):
assert_array_almost_equal(fft(x[i,j,:]),y[i,j,:])
y = fftn(x,axes=(-2,)) # j_line
y = fftn(x,axes=(-2,)) # j_line
for i in range(3):
for j in range(3):
assert_array_almost_equal(fft(x[i,:,j]),y[i,:,j])
y = fftn(x,axes=(0,)) # k_line
y = fftn(x,axes=(0,)) # k_line
for i in range(3):
for j in range(3):
assert_array_almost_equal(fft(x[:,i,j]),y[:,i,j])

y = fftn(x,axes=()) # point
y = fftn(x,axes=()) # point
assert_array_almost_equal(y,x)

def test_shape_argument(self):
Expand All @@ -577,11 +577,11 @@ def test_shape_axes_argument(self):
[7,8,9,0],
[0,0,0,0]])
# Disable tests with shape and axes of different lengths
#y = fftn(small_x,shape=(4,4),axes=(-1,))
#for i in range(4):
# y = fftn(small_x,shape=(4,4),axes=(-1,))
# for i in range(4):
# assert_array_almost_equal (y[i],fft(large_x1[i]))
#y = fftn(small_x,shape=(4,4),axes=(-2,))
#for i in range(4):
# y = fftn(small_x,shape=(4,4),axes=(-2,))
# for i in range(4):
# assert_array_almost_equal (y[:,i],fft(large_x1[:,i]))
y = fftn(small_x,shape=(4,4),axes=(-2,-1))
assert_array_almost_equal(y,fftn(large_x1))
Expand Down
4 changes: 2 additions & 2 deletions scipy/integrate/odepack.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def odeint(func, y0, t, args=(), Dfun=None, col_deriv=0, full_output=0,
"""

if ml is None:
ml = -1 # changed to zero inside function call
ml = -1 # changed to zero inside function call
if mu is None:
mu = -1 # changed to zero inside function call
mu = -1 # changed to zero inside function call
t = copy(t)
y0 = copy(y0)
output = _odepack.odeint(func, y0, t, args, Dfun, col_deriv, ml, mu,
Expand Down
Loading

0 comments on commit 6f9f01d

Please sign in to comment.