-
Notifications
You must be signed in to change notification settings - Fork 16
Fix keyword files with list of lists #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this a bug? Did the code work before when specifying the kwarg files? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK this worked, but the thing is that the files-keyword didn't do anything in this case... With this, it would give you the option to (at least) say which ids you want, however, this is of course nto the same kind of control you have in the other cases, where you can actually say which idls you want. |
||
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: | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if files is not of type list[list[int]]? Maybe we should add an explicit exception here or is there a type check somewhere else that I overlooked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, sorry it took some time, I put explicit type checks in both places where
kwargs.get('files')
is used and just put two tests.