diff --git a/CodeEntropy/entropy/nodes/configurational.py b/CodeEntropy/entropy/nodes/configurational.py index 720db9c..bab634e 100644 --- a/CodeEntropy/entropy/nodes/configurational.py +++ b/CodeEntropy/entropy/nodes/configurational.py @@ -53,7 +53,7 @@ def run(self, shared_data: MutableMapping[str, Any], **_: Any) -> dict[str, Any] fragments = universe.atoms.fragments results: dict[int, dict[str, float]] = {} - for group_id, mol_ids in groups.items(): + for group_id, mol_ids in sorted(groups.items()): results[group_id] = {"ua": 0.0, "res": 0.0, "poly": 0.0} if not mol_ids: continue diff --git a/CodeEntropy/entropy/nodes/orientational.py b/CodeEntropy/entropy/nodes/orientational.py index b3e387e..74b50c5 100644 --- a/CodeEntropy/entropy/nodes/orientational.py +++ b/CodeEntropy/entropy/nodes/orientational.py @@ -52,7 +52,7 @@ def run(self, shared_data: MutableMapping[str, Any], **_: Any) -> dict[str, Any] results: dict[int, float] = {} - for group_id, mol_ids in groups.items(): + for group_id, mol_ids in sorted(groups.items()): results[group_id] = 0 if not mol_ids: continue diff --git a/CodeEntropy/entropy/nodes/vibrational.py b/CodeEntropy/entropy/nodes/vibrational.py index 015749e..f6ed2f8 100644 --- a/CodeEntropy/entropy/nodes/vibrational.py +++ b/CodeEntropy/entropy/nodes/vibrational.py @@ -90,7 +90,7 @@ def run(self, shared_data: MutableMapping[str, Any], **_: Any) -> dict[str, Any] results: dict[int, dict[str, dict[str, float]]] = {} - for group_id, mol_ids in groups.items(): + for group_id, mol_ids in sorted(groups.items()): results[group_id] = {} if not mol_ids: continue @@ -198,7 +198,7 @@ def _get_group_id_to_index(self, shared_data: Mapping[str, Any]) -> dict[int, in if isinstance(gid2i, dict) and gid2i: return gid2i groups = shared_data["groups"] - return {gid: i for i, gid in enumerate(groups.keys())} + return {gid: i for i, gid in enumerate(sorted(groups.keys()))} def _get_ua_frame_counts(self, shared_data: Mapping[str, Any]) -> dict[CovKey, int]: """Extract per-(group,residue) frame counts for united-atom covariances. diff --git a/CodeEntropy/entropy/workflow.py b/CodeEntropy/entropy/workflow.py index fe50e51..b35e259 100644 --- a/CodeEntropy/entropy/workflow.py +++ b/CodeEntropy/entropy/workflow.py @@ -293,7 +293,7 @@ def _split_water_groups( water_groups = { gid: mol_ids - for gid, mol_ids in groups.items() + for gid, mol_ids in sorted(groups.items()) if any( res.resid in water_resids for mol in [universe.atoms.fragments[i] for i in mol_ids] @@ -301,7 +301,7 @@ def _split_water_groups( ) } nonwater_groups = { - gid: g for gid, g in groups.items() if gid not in water_groups + gid: g for gid, g in sorted(groups.items()) if gid not in water_groups } return nonwater_groups, water_groups @@ -354,7 +354,7 @@ def _finalize_molecule_results(self) -> None: except (TypeError, ValueError): logger.warning("Skipping invalid entry: %s, %s", group_id, result) - for group_id, total in entropy_by_group.items(): + for group_id, total in sorted(entropy_by_group.items()): self._reporter.molecule_data.append( (group_id, "Group Total", "Group Total Entropy", total) ) diff --git a/CodeEntropy/levels/nodes/covariance.py b/CodeEntropy/levels/nodes/covariance.py index 27b9edb..25375d4 100644 --- a/CodeEntropy/levels/nodes/covariance.py +++ b/CodeEntropy/levels/nodes/covariance.py @@ -93,7 +93,7 @@ def run(self, ctx: FrameCtx) -> dict[str, Any]: res_molcount: dict[int, int] = {} poly_molcount: dict[int, int] = {} - for group_id, mol_ids in groups.items(): + for group_id, mol_ids in sorted(groups.items()): for mol_id in mol_ids: mol = fragments[mol_id] level_list = levels[mol_id] diff --git a/CodeEntropy/results/reporter.py b/CodeEntropy/results/reporter.py index 0d8abee..3261c25 100644 --- a/CodeEntropy/results/reporter.py +++ b/CodeEntropy/results/reporter.py @@ -408,9 +408,9 @@ def _build_grouped_payload( key = f"{level}:{typ}" groups[gid]["components"][key] = val - for _gid, g in groups.items(): + for g in groups.values(): if g["total"] is None: - comps = g["components"].values() + comps = sorted(g["components"].values()) g["total"] = float(sum(comps)) if comps else 0.0 payload: dict[str, Any] = { diff --git a/tests/regression/baselines/ethyl-acetate/axes_off.json b/tests/regression/baselines/ethyl-acetate/axes_off.json index 7b43a98..ada5c38 100644 --- a/tests/regression/baselines/ethyl-acetate/axes_off.json +++ b/tests/regression/baselines/ethyl-acetate/axes_off.json @@ -1,10 +1,10 @@ { "args": { "top_traj_file": [ - "/home/harry-swift/BioSim/software/CodeEntropy/.testdata/benzaldehyde/molecules.top", - "/home/harry-swift/BioSim/software/CodeEntropy/.testdata/benzaldehyde/trajectory.crd" + "/home/harry-swift/BioSim/software/CodeEntropy/.testdata/ethyl-acetate/molecules.top", + "/home/harry-swift/BioSim/software/CodeEntropy/.testdata/ethyl-acetate/trajectory.crd" ], - "force_file": "/home/harry-swift/BioSim/software/CodeEntropy/.testdata/benzaldehyde/forces.frc", + "force_file": "/home/harry-swift/BioSim/software/CodeEntropy/.testdata/ethyl-acetate/forces.frc", "file_format": "MDCRD", "kcal_force_units": true, "selection_string": "resid 1:10", @@ -14,7 +14,7 @@ "bin_width": 30, "temperature": 298.0, "verbose": false, - "output_file": "/tmp/pytest-of-harry-swift/pytest-47/test_regression_matches_baseli0/job001/output_file.json", + "output_file": "/tmp/pytest-of-harry-swift/pytest-1/popen-gw0/test_regression_matches_baseli0/job001/output_file.json", "force_partitioning": 0.5, "water_entropy": true, "grouping": "molecules", @@ -24,22 +24,22 @@ }, "provenance": { "python": "3.14.3", - "platform": "Linux-6.17.0-19-generic-x86_64-with-glibc2.39", + "platform": "Linux-6.17.0-20-generic-x86_64-with-glibc2.39", "codeentropy_version": "2.1.0", - "git_sha": "be46d826f4ae38e3c6e62a7d5bcddeca85e31590" + "git_sha": "35b54c7d4ea40dac345db7fe8f6a0285bf6852e8" }, "groups": { "0": { "components": { - "united_atom:Transvibrational": 0.08982962903796131, - "united_atom:Rovibrational": 32.16018134884085, - "residue:FTmat-Transvibrational": 88.7671666695003, - "residue:FTmat-Rovibrational": 61.61036267672132, - "united_atom:Conformational": 0.0, + "united_atom:Transvibrational": 1.2655393305199973, + "united_atom:Rovibrational": 68.85184585731292, + "residue:FTmat-Transvibrational": 77.33844477785695, + "residue:FTmat-Rovibrational": 56.03921993686319, + "united_atom:Conformational": 8.140778318198597, "residue:Conformational": 0.0, - "residue:Orientational": 7.791711490122748 + "residue:Orientational": 3.2718547817092687 }, - "total": 190.41925181422317 + "total": 214.9076830024609 } } } diff --git a/tests/regression/configs/ethyl-acetate/axes_off.yaml b/tests/regression/configs/ethyl-acetate/axes_off.yaml index a733dda..6ffdad3 100644 --- a/tests/regression/configs/ethyl-acetate/axes_off.yaml +++ b/tests/regression/configs/ethyl-acetate/axes_off.yaml @@ -1,10 +1,10 @@ --- run1: - force_file: ".testdata/benzaldehyde/forces.frc" + force_file: ".testdata/ethyl-acetate/forces.frc" top_traj_file: - - ".testdata/benzaldehyde/molecules.top" - - ".testdata/benzaldehyde/trajectory.crd" + - ".testdata/ethyl-acetate/molecules.top" + - ".testdata/ethyl-acetate/trajectory.crd" selection_string: "resid 1:10" start: 0 end: 1