PEP8 code cleanups.

这个提交包含在:
Craig Warren
2018-01-02 18:14:20 +00:00
父节点 f83ec97fa9
当前提交 4848a8d4d7
共有 15 个文件被更改,包括 83 次插入90 次删除

查看文件

@@ -29,7 +29,7 @@ kernels_template_fields = Template("""
#define INDEX4D_ID(p, i, j, k) (p)*($NX_ID)*($NY_ID)*($NZ_ID)+(i)*($NY_ID)*($NZ_ID)+(j)*($NZ_ID)+(k)
#define INDEX4D_T(p, i, j, k) (p)*($NX_T)*($NY_T)*($NZ_T)+(i)*($NY_T)*($NZ_T)+(j)*($NZ_T)+(k)
// Material coefficients (read-only) in constant memory (64KB)
// Material coefficients (read-only) in constant memory (64KB)_
__device__ __constant__ $REAL updatecoeffsE[$N_updatecoeffsE];
__device__ __constant__ $REAL updatecoeffsH[$N_updatecoeffsH];

查看文件

@@ -398,7 +398,7 @@ def run_mpi_sim(args, inputfile, usernamespace, optparams=None):
try:
comm = MPI.Comm.Get_parent() # get MPI communicator object
rank = comm.Get_rank() # rank of this process
except:
except ValueError:
raise ValueError('Could not connect to parent')
# Ask for work until stop sentinel

查看文件

@@ -50,10 +50,10 @@ class Grid(object):
self.grid = grid
def n_edges(self):
l = self.nx
m = self.ny
n = self.nz
e = (l * m * (n - 1)) + (m * n * (l - 1)) + (l * n * (m - 1))
i = self.nx
j = self.ny
k = self.nz
e = (i * j * (k - 1)) + (j * k * (i - 1)) + (i * k * (j - 1))
return e
def n_nodes(self):
@@ -261,7 +261,7 @@ def dispersion_analysis(G):
try:
freqthres = np.where(power[freqmaxpower:] < -G.highestfreqthres)[0][0] + freqmaxpower
results['maxfreq'].append(freqs[freqthres])
except:
except ValueError:
results['error'] = 'unable to calculate maximum power from waveform, most likely due to undersampling.'
# If waveform is truncated don't do any further analysis

查看文件

@@ -877,10 +877,7 @@ def process_geometrycmds(geometry, G):
volume.nbins = nbins
volume.seed = seed
volume.weighting = np.array([float(tmp[8]), float(tmp[9]), float(tmp[10])])
try:
volume.averaging = averagefractalbox
except:
pass
if G.messages:
if volume.averaging:

查看文件

@@ -499,7 +499,7 @@ def process_multicmds(multicmds, G):
try:
time = int(tmp[9])
# If real floating point value given
except:
except ValueError:
time = float(tmp[9])
if time > 0:
time = round_value((time / G.dt)) + 1
@@ -587,13 +587,8 @@ def process_multicmds(multicmds, G):
material.type = 'debye'
material.poles = poles
material.averagable = False
# for pole in range(1, 2 * poles, 2):
# if float(tmp[pole]) > 0 and float(tmp[pole + 1]) > G.dt:
# material.deltaer.append(float(tmp[pole]))
# material.tau.append(float(tmp[pole + 1]))
# else:
# raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' requires positive values for the permittivity difference, and relaxation times that are greater than the time step for the model.')
for pole in range(1, 2 * poles, 2):
# N.B Not checking if relaxation times are greater than time-step
if float(tmp[pole]) > 0:
material.deltaer.append(float(tmp[pole]))
material.tau.append(float(tmp[pole + 1]))

查看文件

@@ -203,7 +203,7 @@ def process_singlecmds(singlecmds, G):
G.timewindow = (tmp - 1) * G.dt
G.iterations = tmp
# If real floating point value given
except:
except ValueError:
tmp = float(tmp)
if tmp > 0:
G.timewindow = tmp

查看文件

@@ -153,7 +153,7 @@ class Material(object):
er (float): Complex relative permittivity.
"""
# This will be permittivity at infinite frequency if the material is dispersive
# Permittivity at infinite frequency if the material is dispersive
er = self.er
if self.poles > 0:
@@ -166,6 +166,7 @@ class Material(object):
for pole in range(self.poles):
er += (self.deltaer[pole] * self.tau[pole]**2) / (self.tau[pole]**2 + 2j * w * self.alpha[pole] - w**2)
elif 'drude' in self.type:
ersum = 0
for pole in range(self.poles):
ersum += self.tau[pole]**2 / (w**2 - 1j * w * self.alpha[pole])
er -= ersum

查看文件

@@ -152,7 +152,7 @@ def fft_power(waveform, dt):
"""
# Calculate magnitude of frequency spectra of waveform (ignore warning from taking a log of any zero values)
with np.errstate(divide='ignore'): #
with np.errstate(divide='ignore'):
power = 10 * np.log10(np.abs(np.fft.fft(waveform))**2)
# Replace any NaNs or Infs from zero division