mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
Fix keyword files with list of lists (#226)
* first impl. handle reps with list of lists * implement explicit type checks
This commit is contained in:
parent
43383acead
commit
b930fab9c2
2 changed files with 65 additions and 3 deletions
|
@ -121,7 +121,7 @@ def read_sfcf_multi(path, prefix, name_list, quarks_list=['.*'], corr_type_list=
|
|||
String that separates the ensemble identifier from the configuration number (default 'n').
|
||||
replica: list
|
||||
list of replica to be read, default is all
|
||||
files: list
|
||||
files: list[list[int]]
|
||||
list of files to be read per replica, default is all.
|
||||
for non-compact output format, hand the folders to be read here.
|
||||
check_configs: list[list[int]]
|
||||
|
@ -236,6 +236,16 @@ def read_sfcf_multi(path, prefix, name_list, quarks_list=['.*'], corr_type_list=
|
|||
rep_path = path + '/' + item
|
||||
if "files" in kwargs:
|
||||
files = kwargs.get("files")
|
||||
if isinstance(files, list):
|
||||
if all(isinstance(f, list) for f in files):
|
||||
files = files[i]
|
||||
elif all(isinstance(f, str) for f in files):
|
||||
files = files
|
||||
else:
|
||||
raise TypeError("files has to be of type list[list[str]] or list[str]!")
|
||||
else:
|
||||
raise TypeError("files has to be of type list[list[str]] or list[str]!")
|
||||
|
||||
else:
|
||||
files = []
|
||||
sub_ls = _find_files(rep_path, prefix, compact, files)
|
||||
|
@ -248,7 +258,7 @@ def read_sfcf_multi(path, prefix, name_list, quarks_list=['.*'], corr_type_list=
|
|||
else:
|
||||
rep_idl.append(int(cfg[3:]))
|
||||
except Exception:
|
||||
raise Exception("Couldn't parse idl from directroy, problem with file " + cfg)
|
||||
raise Exception("Couldn't parse idl from directory, problem with file " + cfg)
|
||||
rep_idl.sort()
|
||||
# maybe there is a better way to print the idls
|
||||
if not silent:
|
||||
|
@ -309,7 +319,10 @@ def read_sfcf_multi(path, prefix, name_list, quarks_list=['.*'], corr_type_list=
|
|||
w = specs[3]
|
||||
w2 = specs[4]
|
||||
if "files" in kwargs:
|
||||
ls = kwargs.get("files")
|
||||
if isinstance(kwargs.get("files"), list) and all(isinstance(f, str) for f in kwargs.get("files")):
|
||||
name_ls = kwargs.get("files")
|
||||
else:
|
||||
raise TypeError("In append mode, files has to be of type list[str]!")
|
||||
else:
|
||||
name_ls = ls
|
||||
for exc in name_ls:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue