Skip to content

Commit 47f8e20

Browse files
committed
adding test for flexible dihedral force halving
1 parent 9fb4198 commit 47f8e20

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

tests/unit/CodeEntropy/entropy/test_vibrational_entropy_math.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,12 @@ def test_vibrational_entropy_calculation_end_to_end_returns_float(
159159

160160
assert isinstance(out, float)
161161
assert out >= 0.0
162+
163+
164+
def test_flexible_dihedral(run_manager):
165+
ve = VibrationalEntropy(run_manager=run_manager)
166+
lambdas = [2.0, 3.0, 4.0]
167+
flexible = 2
168+
lambdas = ve._flexible_dihedral(lambdas, flexible)
169+
170+
assert lambdas == [1.0, 0.75, 2.0]

tests/unit/CodeEntropy/levels/test_dihedrals.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ def run(self):
220220
)
221221

222222
assert states == ["0", "1", "0", "1"]
223+
assert num_flexible == 1
223224

224225

225226
def test_assign_states_for_group_sets_empty_lists_and_delegates_for_nonempty():
@@ -252,6 +253,8 @@ def test_assign_states_for_group_sets_empty_lists_and_delegates_for_nonempty():
252253
assert states_ua[(1, 0)] == []
253254
assert states_ua[(1, 1)] == ["x"]
254255
assert states_res[1] == []
256+
assert flexible_ua == {(1, 0): 0, (1, 1): 0}
257+
assert flexible_res == [None, 0]
255258
assert assign_spy.call_count == 1
256259

257260

@@ -280,6 +283,8 @@ def test_build_conformational_states_runs_group_and_skips_empty_group(monkeypatc
280283

281284
assert states_ua == {}
282285
assert len(states_res) == 2
286+
assert flex_ua == {}
287+
assert flex_res == [0, 0]
283288

284289

285290
def test_identify_peaks_handles_multiple_dihedrals_and_calls_histogram_each_time():
@@ -352,6 +357,7 @@ def run(self):
352357
)
353358

354359
assert out_state == []
360+
assert out_flex == 0
355361

356362

357363
def test_identify_peaks_multiple_molecules_real_histogram():
@@ -447,6 +453,7 @@ def test_assign_states_for_group_residue_nonempty_calls_assign_states():
447453
)
448454

449455
assert states_res[1] == ["A"]
456+
assert flexible_res[1] == 0
450457
spy.assert_called_once()
451458

452459

@@ -482,6 +489,7 @@ def run(self):
482489
)
483490

484491
assert states == ["0"]
492+
assert num_flex == 0
485493

486494

487495
def test_collect_peaks_for_group_calls_identify_peaks_for_ua_and_residue():
@@ -542,6 +550,7 @@ def run(self):
542550
)
543551

544552
assert states == ["1", "0"]
553+
assert num_flex == 1
545554

546555

547556
def test_build_conformational_states_with_progress_handles_no_groups():
@@ -592,6 +601,8 @@ def test_build_conformational_states_with_progress_skips_empty_molecule_group():
592601

593602
assert states_ua == {}
594603
assert len(states_res) == 1
604+
assert flex_ua == {}
605+
assert flex_res == [0]
595606
progress.update.assert_called_with(5, title="Group 0 (empty)")
596607
progress.advance.assert_called_with(5)
597608

0 commit comments

Comments
 (0)