Skip to content

Commit abce5f1

Browse files
committed
Add test to verify zero entropy is logged when conformational state data is missing
1 parent 94fc66a commit abce5f1

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

tests/test_CodeEntropy/test_entropy.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,46 @@ def test_process_conformational_residue_level(self):
777777
results = [entry[3] for entry in df]
778778
self.assertIn(3.33, results)
779779

780+
def test_process_conformational_entropy_no_states_entry(self):
781+
"""
782+
Tests that `_process_conformational_entropy` logs zero entropy when
783+
the group_id is not present in the states dictionary.
784+
"""
785+
# Setup minimal mock universe
786+
u = MagicMock()
787+
788+
# Setup managers and arguments
789+
args = MagicMock()
790+
run_manager = MagicMock()
791+
level_manager = MagicMock()
792+
data_logger = DataLogger()
793+
group_molecules = MagicMock()
794+
manager = EntropyManager(
795+
run_manager, args, u, data_logger, level_manager, group_molecules
796+
)
797+
798+
# States dict does NOT contain group_id=1
799+
states = {0: np.ones((10, 3))}
800+
801+
# Mock entropy calculator
802+
ce = MagicMock()
803+
804+
# Run method with group_id=1 (not in states)
805+
manager._process_conformational_entropy(
806+
group_id=1,
807+
mol_container=MagicMock(),
808+
ce=ce,
809+
level="residue",
810+
states=states,
811+
number_frames=10,
812+
)
813+
814+
# Assert entropy is zero
815+
self.assertEqual(data_logger.molecule_data[0][3], 0)
816+
817+
# Assert calculator was not called
818+
ce.conformational_entropy_calculation.assert_not_called()
819+
780820
def test_compute_entropies_united_atom(self):
781821
"""
782822
Test that _process_united_atom_entropy is called correctly for 'united_atom'

0 commit comments

Comments
 (0)