Skip to content

Commit 67673e4

Browse files
authored
Merge pull request #302 from OpenBioSim/fix_301
Fix issue #301
2 parents 9d43587 + f7b63c9 commit 67673e4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

doc/source/changelog.rst

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ organisation on `GitHub <https://github.com/openbiosim/sire>`__.
2424
* Preserve molecule name when reading from SDF format and on conversion to RDKit.
2525
* Handle missing velocity data for ``AMBER`` RST7 files with only a few atoms.
2626
* Preserve SDF metadata when converting to ``RDKIt`` format.
27+
* Fixed unbound local variable when simulation lambda value is not in ``lambda_windows`` array.
2728

2829
`2024.4.0 <https://github.com/openbiosim/sire/compare/2024.3.1...2024.4.0>`__ - Feb 2025
2930
----------------------------------------------------------------------------------------

src/sire/mol/_dynamics.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -437,15 +437,18 @@ def _exit_dynamics_block(
437437
# lambda windows list
438438
try:
439439
lambda_index = lambda_windows.index(sim_lambda_value)
440+
has_lambda_index = True
440441
except:
441-
num_energy_neighbours = num_lambda_windows
442-
lambda_index = i
442+
has_lambda_index = False
443443

444444
for i, (lambda_value, rest2_scale) in enumerate(
445445
zip(lambda_windows, rest2_scale_factors)
446446
):
447447
if lambda_value != sim_lambda_value:
448-
if abs(lambda_index - i) <= num_energy_neighbours:
448+
if (
449+
not has_lambda_index
450+
or abs(lambda_index - i) <= num_energy_neighbours
451+
):
449452
self._omm_mols.set_lambda(
450453
lambda_value,
451454
rest2_scale=rest2_scale,

0 commit comments

Comments
 (0)