fix types for r_start and r_stop, also for postfix

This commit is contained in:
Justus Kuhlmann 2025-11-03 14:26:42 +00:00
commit c822811e44

View file

@ -210,8 +210,8 @@ def read_rwms(path: str, prefix: str, version: str='2.0', names: Optional[list[s
result = [] result = []
idl = [range(configlist[rep][r_start_index[rep]], configlist[rep][r_stop_index[rep]] + 1, r_step) for rep in range(replica)] idl = [range(configlist[rep][r_start_index[rep]], configlist[rep][r_stop_index[rep]] + 1, r_step) for rep in range(replica)]
for t in range(nrw): for k in range(nrw):
result.append(Obs(deltas[t], rep_names, idl=idl)) result.append(Obs(deltas[k], rep_names, idl=idl))
return result return result
@ -277,11 +277,11 @@ def _extract_flowed_energy_density(path: str, prefix: str, dtr_read: int, xmin:
replica = len(ls) replica = len(ls)
r_start: list[Union[int, None]] = kwargs.get('r_start', [None] * replica) r_start: list[int] = kwargs.get('r_start', [0] * replica)
if len(r_start) != replica: if len(r_start) != replica:
raise Exception('r_start does not match number of replicas') raise Exception('r_start does not match number of replicas')
r_stop: list[Union[int, None]] = kwargs.get('r_stop', [None] * replica) r_stop: list[int] = kwargs.get('r_stop', [-1] * replica)
if len(r_stop) != replica: if len(r_stop) != replica:
raise Exception('r_stop does not match number of replicas') raise Exception('r_stop does not match number of replicas')
@ -355,7 +355,7 @@ def _extract_flowed_energy_density(path: str, prefix: str, dtr_read: int, xmin:
offset = configlist[-1][0] - 1 offset = configlist[-1][0] - 1
configlist[-1] = [item - offset for item in configlist[-1]] configlist[-1] = [item - offset for item in configlist[-1]]
if r_start[rep] is None: if r_start[rep] == 0:
r_start_index.append(0) r_start_index.append(0)
else: else:
try: try:
@ -364,7 +364,7 @@ def _extract_flowed_energy_density(path: str, prefix: str, dtr_read: int, xmin:
raise Exception('Config %d not in file with range [%d, %d]' % ( raise Exception('Config %d not in file with range [%d, %d]' % (
r_start[rep], configlist[-1][0], configlist[-1][-1])) from None r_start[rep], configlist[-1][0], configlist[-1][-1])) from None
if r_stop[rep] is None: if r_stop[rep] == -1:
r_stop_index.append(len(configlist[-1]) - 1) r_stop_index.append(len(configlist[-1]) - 1)
else: else:
try: try:
@ -818,43 +818,36 @@ def _read_flow_obs(path: str, prefix: str, c: float, dtr_cnfg: int=1, version: s
raise Exception("Unknown openQCD version.") raise Exception("Unknown openQCD version.")
if "steps" in kwargs: if "steps" in kwargs:
steps = kwargs.get("steps") steps = kwargs.get("steps")
postfix = kwargs.get("postfix", "")
if version == "sfqcd": if version == "sfqcd":
if "L" in kwargs: if "L" in kwargs:
supposed_L = kwargs.get("L") supposed_L = kwargs.get("L")
else: else:
supposed_L = None supposed_L = None
if postfix == "":
postfix = "gfms" postfix = "gfms"
else: else:
if "L" not in kwargs: if "L" not in kwargs:
raise Exception("This version of openQCD needs you to provide the spatial length of the lattice as parameter 'L'.") raise Exception("This version of openQCD needs you to provide the spatial length of the lattice as parameter 'L'.")
else: else:
L = kwargs.get("L") L = kwargs.get("L")
if postfix == "":
postfix = "ms" postfix = "ms"
if "postfix" in kwargs: known_files = kwargs.get("files", [])
postfix = kwargs.get("postfix")
if "files" in kwargs:
known_files = kwargs.get("files")
else:
known_files = []
files = _find_files(path, prefix, postfix, "dat", known_files=known_files) files = _find_files(path, prefix, postfix, "dat", known_files=known_files)
replica = len(files)
if 'r_start' in kwargs: r_start = kwargs.get('r_start', [0] * replica)
r_start = kwargs.get('r_start') if len(r_start) != replica:
if len(r_start) != len(files): raise ValueError('r_start does not match number of replicas')
raise Exception('r_start does not match number of replicas')
r_start = [o if o else None for o in r_start] r_stop = kwargs.get('r_stop', [-1] * replica)
else: if len(r_stop) != replica:
r_start = [None] * len(files) raise ValueError('r_stop does not match number of replicas')
if 'r_stop' in kwargs:
r_stop = kwargs.get('r_stop')
if len(r_stop) != len(files):
raise Exception('r_stop does not match number of replicas')
else:
r_stop = [None] * len(files)
rep_names = [] rep_names = []
zeuthen = kwargs.get('Zeuthen_flow', False) zeuthen = kwargs.get('Zeuthen_flow', False)
@ -960,7 +953,7 @@ def _read_flow_obs(path: str, prefix: str, c: float, dtr_cnfg: int=1, version: s
offset, offset * steps)) offset, offset * steps))
configlist[-1] = [item - offset for item in configlist[-1]] configlist[-1] = [item - offset for item in configlist[-1]]
if r_start[rep] is None: if r_start[rep] == 0:
r_start_index.append(0) r_start_index.append(0)
else: else:
try: try:
@ -969,7 +962,7 @@ def _read_flow_obs(path: str, prefix: str, c: float, dtr_cnfg: int=1, version: s
raise Exception('Config %d not in file with range [%d, %d]' % ( raise Exception('Config %d not in file with range [%d, %d]' % (
r_start[rep], configlist[-1][0], configlist[-1][-1])) from None r_start[rep], configlist[-1][0], configlist[-1][-1])) from None
if r_stop[rep] is None: if r_stop[rep] == -1:
r_stop_index.append(len(configlist[-1]) - 1) r_stop_index.append(len(configlist[-1]) - 1)
else: else:
try: try:
@ -1161,7 +1154,7 @@ def read_ms5_xsf(path: str, prefix: str, qc: str, corr: str, sep: str="r", **kwa
# test if the input is correct # test if the input is correct
if qc not in ['dd', 'ud', 'du', 'uu']: if qc not in ['dd', 'ud', 'du', 'uu']:
raise Exception("Unknown quark conbination!") raise Exception("Unknown quark combination!")
if corr not in ["gS", "gP", "gA", "gV", "gVt", "lA", "lV", "lVt", "lT", "lTt", "g1", "l1"]: if corr not in ["gS", "gP", "gA", "gV", "gVt", "lA", "lV", "lVt", "lT", "lTt", "g1", "l1"]:
raise Exception("Unknown correlator!") raise Exception("Unknown correlator!")