Skip to content

Commit 84c81fb

Browse files
committed
Convert Sire containers to lists prior to comparison.
1 parent 7f11c40 commit 84c81fb

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/somd2/io/_io.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,6 @@ def yaml_to_dict(path):
142142
except Exception as e:
143143
raise ValueError(f"Could not load YAML file: {e}")
144144

145-
# Convert Sire containers to lists.
146-
for key, value in d.items():
147-
try:
148-
d[key] = value.to_list()
149-
except:
150-
pass
151-
152145
return d
153146

154147

src/somd2/runner/_base.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,12 +880,22 @@ def _compare_configs(config1, config2):
880880
if isinstance(v2, _GeneralUnit):
881881
v2 = str(v2)
882882

883-
# If one is from sire and the other is not, will raise error even though they are the same.
883+
# Convert Sire containers to lists for comparison.
884+
try:
885+
v1 = v1.to_list()
886+
except:
887+
pass
888+
try:
889+
v2 = v2.to_list()
890+
except:
891+
pass
892+
884893
if (v1 == None and v2 == False) or (v2 == None and v1 == False):
885894
continue
886895
elif v1 != v2:
887896
raise ValueError(
888-
f"{key} has changed since the last run. This is not allowed when using the restart option."
897+
f"{key} has changed since the last run. This is not "
898+
"allowed when using the restart option."
889899
)
890900

891901
def _verify_restart_config(self):

0 commit comments

Comments
 (0)