Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions process/core/io/in_dat/create.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I actually think this entire function could do with a re-work.

Even with your fixes there are still a number of issues:

  • Negative indexing only works for -1, any other index defaults to scan point 1.
  • Scan point 0 silently updates to 1.
  • Scan point > number of scans will select the last scan.

I'm also not sure I like the for loop looking for a scan. I think this logic should be simplified so that:

  1. We only support scans [1, num_scans] and -1, anything else raises an error.
  2. We only check the requested scan (position) for feasibility and error if it is infeasible. In my opinion, if the user wants a scan point they should explicitly index it, we shouldn't be silently searching for a feasible one.

Let me know if you disagree, have any suggestions, or questions.

Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ def feasible_point(filename, position: int):

check_point = 1

for value in mfile_data.data:
# Look for feasible scan points (with ifail = 1)
if "ifail" in value and "vmcon_error_flag_(ifail)" not in value:
if mfile_data.get(value, scan=check_point) == 1:
scan_point = check_point
if check_point == position:
break
check_point += 1
for scan in range(1, num_scans + 1):
if mfile_data.get("ifail", scan=scan) == 1:
scan_point = scan
if check_point == position:
break
check_point += 1
else:
raise ValueError("No feasible point found")
return scan_point
Expand Down
Loading