Skip to content

Commit b3a566b

Browse files
authored
Merge pull request #280 from fjclark/bugfix-force-specific-equation
Fix hasForceSpecificEquation
2 parents 961e15e + 3cbe190 commit b3a566b

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

corelib/src/libs/SireCAS/lambdaschedule.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -1032,8 +1032,12 @@ bool LambdaSchedule::hasForceSpecificEquation(const QString &stage,
10321032

10331033
if (force == "*")
10341034
return false;
1035-
else
1036-
return this->stage_equations[idx].contains(_get_lever_name(force, lever));
1035+
1036+
// If there is a default equation for this force, always return true
1037+
if (this->stage_equations[idx].contains(_get_lever_name(force, "*")))
1038+
return true;
1039+
1040+
return this->stage_equations[idx].contains(_get_lever_name(force, lever));
10371041
}
10381042

10391043
SireCAS::Expression LambdaSchedule::_getEquation(int stage,

doc/source/changelog.rst

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ organisation on `GitHub <https://github.com/openbiosim/sire>`__.
3939

4040
* Allow user to compute energy trajectory over a subset of the lambda windows for each lambda.
4141

42+
* Fix the ``hasForceSpecificEquation`` function in the ``LambdaLever`` class so that it returns true if
43+
there is a default equation for the force.
44+
4245
`2024.3.1 <https://github.com/openbiosim/sire/compare/2024.3.0...2024.3.1>`__ - December 2024
4346
--------------------------------------------------------------------------------------------
4447

tests/cas/test_lambdaschedule.py

+8
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,11 @@ def test_lambdaschedule():
145145
)
146146

147147
_assert_same_equation(l.lam(), l.get_equation(stage="scale_up"), morph5_equation)
148+
149+
@pytest.mark.parametrize("force, lever, contained", [
150+
("ghost-14", "kappa", True),
151+
("ghost-14", "epsilon", True)
152+
])
153+
def test_has_force_specific_equation(force, lever, contained):
154+
l = sr.cas.LambdaSchedule.standard_decouple()
155+
assert l.has_force_specific_equation("decouple", force, lever) == contained

0 commit comments

Comments
 (0)