Skip to content

Commit

Permalink
Merge pull request #32 from molssi-seamm/dev
Browse files Browse the repository at this point in the history
Bugfix: error in selection of table rows
  • Loading branch information
seamm authored Nov 19, 2024
2 parents cec871a + 1a57917 commit 2b7d85f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
=======
History
=======
2024.11.19: Bugfix: error in selection of table rows
* In a loop "For rows in table" a crietrion on the value of a row might cause an
error due to mismatch of the types. This is now corrected.

2024.11.18: Removed automatic output of structures.
* While often convenient, writing out the structure at the end of the loop was not a
reasonable default. If you want the structure, add a write_structure step in the
Expand Down
18 changes: 10 additions & 8 deletions loop_step/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,29 +545,31 @@ def run(self):
row = self.table.iloc[self._loop_value - 1]

self.logger.debug(f"Query {row[column]} {op} {value}")
_type = type(row[column])
_value = _type(value)
if op == "==":
if row[column] == value:
if row[column] == _value:
break
elif op == "!=":
if row[column] != value:
if row[column] != _value:
break
elif op == ">":
if row[column] > value:
if row[column] > _value:
break
elif op == ">=":
if row[column] >= value:
if row[column] >= _value:
break
elif op == "<":
if row[column] < value:
if row[column] < _value:
break
elif op == "<=":
if row[column] <= value:
if row[column] <= _value:
break
elif op == "contains":
if value in row[column]:
if _value in row[column]:
break
elif op == "does not contain":
if value not in row[column]:
if _value not in row[column]:
break
elif op == "contains regexp":
if re.search(value, row[column]) is not None:
Expand Down

0 comments on commit 2b7d85f

Please sign in to comment.