flake8 formatting improvements

This commit is contained in:
Fabian Joswig 2021-10-11 13:30:48 +01:00
parent 863ce6ae73
commit d4eaf3f48a
3 changed files with 27 additions and 34 deletions

View file

@ -53,7 +53,7 @@ def read_pbp(path, prefix, **kwargs):
else:
r_stop = [None] * replica
print('Read <bar{psi}\psi> from', prefix[:-1], ',', replica, 'replica', end='')
print(r'Read <bar{psi}\psi> from', prefix[:-1], ',', replica, 'replica', end='')
print_err = 0
if 'print_err' in kwargs:
@ -118,7 +118,7 @@ def read_pbp(path, prefix, **kwargs):
for k in range(nrw):
deltas[k].append(tmp_array[k][r_start[rep]:r_stop[rep]])
print(',', nrw, '<bar{psi}\psi> with', nsrc, 'sources')
print(',', nrw, r'<bar{psi}\psi> with', nsrc, 'sources')
result = []
for t in range(nrw):
result.append(Obs(deltas[t], [(w.split('.'))[0] for w in ls]))

View file

@ -23,7 +23,6 @@ def read_rwms(path, prefix, version='2.0', names=None, **kwargs):
r_stop -- list which contains the last config to be read for each replicum
postfix -- postfix of the file to read, e.g. '.ms1' for openQCD-files
"""
#oqcd versions implemented in this method
known_oqcd_versions = ['1.4', '1.6', '2.0']
if not (version in known_oqcd_versions):
raise Exception('Unknown openQCD version defined!')
@ -46,8 +45,6 @@ def read_rwms(path, prefix, version='2.0', names=None, **kwargs):
ls = list(set(ls) - set([exc]))
if len(ls) > 1:
ls.sort(key=lambda x: int(re.findall(r'\d+', x[len(prefix):])[0]))
#ls = fnames
#print(ls)
replica = len(ls)
if 'r_start' in kwargs:
@ -88,7 +85,7 @@ def read_rwms(path, prefix, version='2.0', names=None, **kwargs):
for k in range(nrw):
deltas.append([])
else:
if ((nrw != struct.unpack('i', t)[0] and (not verion == '2.0')) or (nrw != struct.unpack('i', t)[0]/2 and version == '2.0')):# little weird if-clause due to the /2 operation needed.
if ((nrw != struct.unpack('i', t)[0] and (not version == '2.0')) or (nrw != struct.unpack('i', t)[0] / 2 and version == '2.0')): # little weird if-clause due to the /2 operation needed.
raise Exception('Error: different number of reweighting factors for replicum', rep)
for k in range(nrw):
@ -109,7 +106,7 @@ def read_rwms(path, prefix, version='2.0', names=None, **kwargs):
for i in range(nrw):
t = fp.read(4)
nsrc.append(struct.unpack('i', t)[0])
if version is '2.0':
if version == '2.0':
if not struct.unpack('i', fp.read(4))[0] == 0:
print('something is wrong!')
@ -132,7 +129,7 @@ def read_rwms(path, prefix, version='2.0', names=None, **kwargs):
print(config_no, i, j, np.mean(np.exp(-np.asarray(tmp_rw[j]))), np.std(np.exp(-np.asarray(tmp_rw[j]))))
print('Sources:', np.exp(-np.asarray(tmp_rw[j])))
print('Partial factor:', tmp_nfct)
elif version is '1.6' or version is '1.4':
elif version == '1.6' or version == '1.4':
tmp_nfct = 1.0
for j in range(nfct[i]):
t = fp.read(8 * nsrc[i])
@ -151,7 +148,7 @@ def read_rwms(path, prefix, version='2.0', names=None, **kwargs):
print(',', nrw, 'reweighting factors with', nsrc, 'sources')
result = []
for t in range(nrw):
if names == None:
if names is None:
result.append(Obs(deltas[t], [w.split(".")[0] for w in ls]))
else:
print(names)
@ -159,8 +156,6 @@ def read_rwms(path, prefix, version='2.0', names=None, **kwargs):
return result
def extract_t0(path, prefix, dtr_read, xmin, spatial_extent, fit_range=5, **kwargs):
"""Extract t0 from given .ms.dat files. Returns t0 as Obs.

View file

@ -134,9 +134,7 @@ def read_sfcf_c(path, prefix, name, quarks='.*', noffset=0, wf=0, wf2=0, **kwarg
else:
b2b = 0
read = 0
T = 0
start = 0
ls = []
for (dirpath, dirnames, filenames) in os.walk(path):
ls.extend(dirnames)
@ -189,7 +187,7 @@ def read_sfcf_c(path, prefix, name, quarks='.*', noffset=0, wf=0, wf2=0, **kwarg
match = re.search(pattern, content)
if match:
start_read = content.count('\n', 0, match.start()) + 5 + b2b
end_match = re.search('\n\s*\n', content[match.start():])
end_match = re.search(r'\n\s*\n', content[match.start():])
T = content[match.start():].count('\n', 0, end_match.start()) - 4 - b2b
assert T > 0
print(T, 'entries, starting to read in line', start_read)