diff --git a/HISTORY.rst b/HISTORY.rst index 3a876fe..9bf0a55 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -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 diff --git a/loop_step/loop.py b/loop_step/loop.py index 14948f3..3536478 100644 --- a/loop_step/loop.py +++ b/loop_step/loop.py @@ -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 @@ -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) @@ -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