Skip to content

Commit

Permalink
Merge pull request #23 from molssi-seamm/dev
Browse files Browse the repository at this point in the history
Bugfix: logic of For loops lead to crash because directory not made
  • Loading branch information
seamm committed Nov 9, 2023
2 parents 53a9924 + a026dce commit 2d48a4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
=======
History
=======
2023.11.9 -- Bugfix: "For" loops could crash
* For loops could crash writing to write final_structure.mmcif before the directory
had been made.

2023.10.30 -- Improved consistency of printing loop information

2023.4.24 -- Better support for rerunning/restarting jobs
Expand Down
7 changes: 5 additions & 2 deletions loop_step/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, flowchart=None, extension=None):

self.table_handle = None
self.table = None
self._loop_count = None
self._loop_value = None
self._loop_length = None
self._file_handler = None
Expand Down Expand Up @@ -174,6 +175,7 @@ def run(self):
end = int(end)

self.logger.info("Initializing loop")
self._loop_count = 0
self._loop_value = start
self.set_variable(P["variable"], self._loop_value)

Expand Down Expand Up @@ -354,10 +356,11 @@ def run(self):
next_node = self.loop_node()

if P["type"] == "For":
if self._loop_value >= 0:
self._loop_count += 1
if self._loop_count > 1:
self.write_final_structure()
self._loop_value += step

self._loop_value += step
self.set_variable(P["variable"], self._loop_value)

# Set up the index variables
Expand Down

0 comments on commit 2d48a4a

Please sign in to comment.