Skip to content

Commit 192e198

Browse files
authored
Merge pull request #311 from CCPBioSim/310-bug-mismatch-within-regression-test
Enforce deterministic group ordering across entropy pipeline and fix ethyl-acetate regression test topology mismatch
2 parents d662421 + b239fc0 commit 192e198

8 files changed

Lines changed: 26 additions & 26 deletions

File tree

CodeEntropy/entropy/nodes/configurational.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def run(self, shared_data: MutableMapping[str, Any], **_: Any) -> dict[str, Any]
5353
fragments = universe.atoms.fragments
5454
results: dict[int, dict[str, float]] = {}
5555

56-
for group_id, mol_ids in groups.items():
56+
for group_id, mol_ids in sorted(groups.items()):
5757
results[group_id] = {"ua": 0.0, "res": 0.0, "poly": 0.0}
5858
if not mol_ids:
5959
continue

CodeEntropy/entropy/nodes/orientational.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def run(self, shared_data: MutableMapping[str, Any], **_: Any) -> dict[str, Any]
5252

5353
results: dict[int, float] = {}
5454

55-
for group_id, mol_ids in groups.items():
55+
for group_id, mol_ids in sorted(groups.items()):
5656
results[group_id] = 0
5757
if not mol_ids:
5858
continue

CodeEntropy/entropy/nodes/vibrational.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def run(self, shared_data: MutableMapping[str, Any], **_: Any) -> dict[str, Any]
9090

9191
results: dict[int, dict[str, dict[str, float]]] = {}
9292

93-
for group_id, mol_ids in groups.items():
93+
for group_id, mol_ids in sorted(groups.items()):
9494
results[group_id] = {}
9595
if not mol_ids:
9696
continue
@@ -198,7 +198,7 @@ def _get_group_id_to_index(self, shared_data: Mapping[str, Any]) -> dict[int, in
198198
if isinstance(gid2i, dict) and gid2i:
199199
return gid2i
200200
groups = shared_data["groups"]
201-
return {gid: i for i, gid in enumerate(groups.keys())}
201+
return {gid: i for i, gid in enumerate(sorted(groups.keys()))}
202202

203203
def _get_ua_frame_counts(self, shared_data: Mapping[str, Any]) -> dict[CovKey, int]:
204204
"""Extract per-(group,residue) frame counts for united-atom covariances.

CodeEntropy/entropy/workflow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,15 @@ def _split_water_groups(
293293

294294
water_groups = {
295295
gid: mol_ids
296-
for gid, mol_ids in groups.items()
296+
for gid, mol_ids in sorted(groups.items())
297297
if any(
298298
res.resid in water_resids
299299
for mol in [universe.atoms.fragments[i] for i in mol_ids]
300300
for res in mol.residues
301301
)
302302
}
303303
nonwater_groups = {
304-
gid: g for gid, g in groups.items() if gid not in water_groups
304+
gid: g for gid, g in sorted(groups.items()) if gid not in water_groups
305305
}
306306
return nonwater_groups, water_groups
307307

@@ -354,7 +354,7 @@ def _finalize_molecule_results(self) -> None:
354354
except (TypeError, ValueError):
355355
logger.warning("Skipping invalid entry: %s, %s", group_id, result)
356356

357-
for group_id, total in entropy_by_group.items():
357+
for group_id, total in sorted(entropy_by_group.items()):
358358
self._reporter.molecule_data.append(
359359
(group_id, "Group Total", "Group Total Entropy", total)
360360
)

CodeEntropy/levels/nodes/covariance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def run(self, ctx: FrameCtx) -> dict[str, Any]:
9393
res_molcount: dict[int, int] = {}
9494
poly_molcount: dict[int, int] = {}
9595

96-
for group_id, mol_ids in groups.items():
96+
for group_id, mol_ids in sorted(groups.items()):
9797
for mol_id in mol_ids:
9898
mol = fragments[mol_id]
9999
level_list = levels[mol_id]

CodeEntropy/results/reporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,9 @@ def _build_grouped_payload(
408408
key = f"{level}:{typ}"
409409
groups[gid]["components"][key] = val
410410

411-
for _gid, g in groups.items():
411+
for g in groups.values():
412412
if g["total"] is None:
413-
comps = g["components"].values()
413+
comps = sorted(g["components"].values())
414414
g["total"] = float(sum(comps)) if comps else 0.0
415415

416416
payload: dict[str, Any] = {
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"args": {
33
"top_traj_file": [
4-
"/home/harry-swift/BioSim/software/CodeEntropy/.testdata/benzaldehyde/molecules.top",
5-
"/home/harry-swift/BioSim/software/CodeEntropy/.testdata/benzaldehyde/trajectory.crd"
4+
"/home/harry-swift/BioSim/software/CodeEntropy/.testdata/ethyl-acetate/molecules.top",
5+
"/home/harry-swift/BioSim/software/CodeEntropy/.testdata/ethyl-acetate/trajectory.crd"
66
],
7-
"force_file": "/home/harry-swift/BioSim/software/CodeEntropy/.testdata/benzaldehyde/forces.frc",
7+
"force_file": "/home/harry-swift/BioSim/software/CodeEntropy/.testdata/ethyl-acetate/forces.frc",
88
"file_format": "MDCRD",
99
"kcal_force_units": true,
1010
"selection_string": "resid 1:10",
@@ -14,7 +14,7 @@
1414
"bin_width": 30,
1515
"temperature": 298.0,
1616
"verbose": false,
17-
"output_file": "/tmp/pytest-of-harry-swift/pytest-47/test_regression_matches_baseli0/job001/output_file.json",
17+
"output_file": "/tmp/pytest-of-harry-swift/pytest-1/popen-gw0/test_regression_matches_baseli0/job001/output_file.json",
1818
"force_partitioning": 0.5,
1919
"water_entropy": true,
2020
"grouping": "molecules",
@@ -24,22 +24,22 @@
2424
},
2525
"provenance": {
2626
"python": "3.14.3",
27-
"platform": "Linux-6.17.0-19-generic-x86_64-with-glibc2.39",
27+
"platform": "Linux-6.17.0-20-generic-x86_64-with-glibc2.39",
2828
"codeentropy_version": "2.1.0",
29-
"git_sha": "be46d826f4ae38e3c6e62a7d5bcddeca85e31590"
29+
"git_sha": "35b54c7d4ea40dac345db7fe8f6a0285bf6852e8"
3030
},
3131
"groups": {
3232
"0": {
3333
"components": {
34-
"united_atom:Transvibrational": 0.08982962903796131,
35-
"united_atom:Rovibrational": 32.16018134884085,
36-
"residue:FTmat-Transvibrational": 88.7671666695003,
37-
"residue:FTmat-Rovibrational": 61.61036267672132,
38-
"united_atom:Conformational": 0.0,
34+
"united_atom:Transvibrational": 1.2655393305199973,
35+
"united_atom:Rovibrational": 68.85184585731292,
36+
"residue:FTmat-Transvibrational": 77.33844477785695,
37+
"residue:FTmat-Rovibrational": 56.03921993686319,
38+
"united_atom:Conformational": 8.140778318198597,
3939
"residue:Conformational": 0.0,
40-
"residue:Orientational": 7.791711490122748
40+
"residue:Orientational": 3.2718547817092687
4141
},
42-
"total": 190.41925181422317
42+
"total": 214.9076830024609
4343
}
4444
}
4545
}

tests/regression/configs/ethyl-acetate/axes_off.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22

33
run1:
4-
force_file: ".testdata/benzaldehyde/forces.frc"
4+
force_file: ".testdata/ethyl-acetate/forces.frc"
55
top_traj_file:
6-
- ".testdata/benzaldehyde/molecules.top"
7-
- ".testdata/benzaldehyde/trajectory.crd"
6+
- ".testdata/ethyl-acetate/molecules.top"
7+
- ".testdata/ethyl-acetate/trajectory.crd"
88
selection_string: "resid 1:10"
99
start: 0
1010
end: 1

0 commit comments

Comments
 (0)