mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-06-30 08:49:28 +02:00
flake8 formatting improvements
This commit is contained in:
parent
863ce6ae73
commit
d4eaf3f48a
3 changed files with 27 additions and 34 deletions
|
@ -53,7 +53,7 @@ def read_pbp(path, prefix, **kwargs):
|
||||||
else:
|
else:
|
||||||
r_stop = [None] * replica
|
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
|
print_err = 0
|
||||||
if 'print_err' in kwargs:
|
if 'print_err' in kwargs:
|
||||||
|
@ -118,7 +118,7 @@ def read_pbp(path, prefix, **kwargs):
|
||||||
for k in range(nrw):
|
for k in range(nrw):
|
||||||
deltas[k].append(tmp_array[k][r_start[rep]:r_stop[rep]])
|
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 = []
|
result = []
|
||||||
for t in range(nrw):
|
for t in range(nrw):
|
||||||
result.append(Obs(deltas[t], [(w.split('.'))[0] for w in ls]))
|
result.append(Obs(deltas[t], [(w.split('.'))[0] for w in ls]))
|
||||||
|
|
|
@ -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
|
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
|
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']
|
known_oqcd_versions = ['1.4', '1.6', '2.0']
|
||||||
if not (version in known_oqcd_versions):
|
if not (version in known_oqcd_versions):
|
||||||
raise Exception('Unknown openQCD version defined!')
|
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]))
|
ls = list(set(ls) - set([exc]))
|
||||||
if len(ls) > 1:
|
if len(ls) > 1:
|
||||||
ls.sort(key=lambda x: int(re.findall(r'\d+', x[len(prefix):])[0]))
|
ls.sort(key=lambda x: int(re.findall(r'\d+', x[len(prefix):])[0]))
|
||||||
#ls = fnames
|
|
||||||
#print(ls)
|
|
||||||
replica = len(ls)
|
replica = len(ls)
|
||||||
|
|
||||||
if 'r_start' in kwargs:
|
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):
|
for k in range(nrw):
|
||||||
deltas.append([])
|
deltas.append([])
|
||||||
else:
|
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)
|
raise Exception('Error: different number of reweighting factors for replicum', rep)
|
||||||
|
|
||||||
for k in range(nrw):
|
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):
|
for i in range(nrw):
|
||||||
t = fp.read(4)
|
t = fp.read(4)
|
||||||
nsrc.append(struct.unpack('i', t)[0])
|
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:
|
if not struct.unpack('i', fp.read(4))[0] == 0:
|
||||||
print('something is wrong!')
|
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(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('Sources:', np.exp(-np.asarray(tmp_rw[j])))
|
||||||
print('Partial factor:', tmp_nfct)
|
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
|
tmp_nfct = 1.0
|
||||||
for j in range(nfct[i]):
|
for j in range(nfct[i]):
|
||||||
t = fp.read(8 * nsrc[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')
|
print(',', nrw, 'reweighting factors with', nsrc, 'sources')
|
||||||
result = []
|
result = []
|
||||||
for t in range(nrw):
|
for t in range(nrw):
|
||||||
if names == None:
|
if names is None:
|
||||||
result.append(Obs(deltas[t], [w.split(".")[0] for w in ls]))
|
result.append(Obs(deltas[t], [w.split(".")[0] for w in ls]))
|
||||||
else:
|
else:
|
||||||
print(names)
|
print(names)
|
||||||
|
@ -159,8 +156,6 @@ def read_rwms(path, prefix, version='2.0', names=None, **kwargs):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def extract_t0(path, prefix, dtr_read, xmin, spatial_extent, fit_range=5, **kwargs):
|
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.
|
"""Extract t0 from given .ms.dat files. Returns t0 as Obs.
|
||||||
|
|
||||||
|
|
|
@ -134,9 +134,7 @@ def read_sfcf_c(path, prefix, name, quarks='.*', noffset=0, wf=0, wf2=0, **kwarg
|
||||||
else:
|
else:
|
||||||
b2b = 0
|
b2b = 0
|
||||||
|
|
||||||
read = 0
|
|
||||||
T = 0
|
T = 0
|
||||||
start = 0
|
|
||||||
ls = []
|
ls = []
|
||||||
for (dirpath, dirnames, filenames) in os.walk(path):
|
for (dirpath, dirnames, filenames) in os.walk(path):
|
||||||
ls.extend(dirnames)
|
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)
|
match = re.search(pattern, content)
|
||||||
if match:
|
if match:
|
||||||
start_read = content.count('\n', 0, match.start()) + 5 + b2b
|
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
|
T = content[match.start():].count('\n', 0, end_match.start()) - 4 - b2b
|
||||||
assert T > 0
|
assert T > 0
|
||||||
print(T, 'entries, starting to read in line', start_read)
|
print(T, 'entries, starting to read in line', start_read)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue