Skip to content

Commit

Permalink
Merge pull request #280 from fjclark/bugfix-force-specific-equation
Browse files Browse the repository at this point in the history
Fix hasForceSpecificEquation
  • Loading branch information
lohedges authored Jan 30, 2025
2 parents 961e15e + 3cbe190 commit b3a566b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions corelib/src/libs/SireCAS/lambdaschedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,12 @@ bool LambdaSchedule::hasForceSpecificEquation(const QString &stage,

if (force == "*")
return false;
else
return this->stage_equations[idx].contains(_get_lever_name(force, lever));

// If there is a default equation for this force, always return true
if (this->stage_equations[idx].contains(_get_lever_name(force, "*")))
return true;

return this->stage_equations[idx].contains(_get_lever_name(force, lever));
}

SireCAS::Expression LambdaSchedule::_getEquation(int stage,
Expand Down
3 changes: 3 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ organisation on `GitHub <https://github.com/openbiosim/sire>`__.

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

* Fix the ``hasForceSpecificEquation`` function in the ``LambdaLever`` class so that it returns true if
there is a default equation for the force.

`2024.3.1 <https://github.com/openbiosim/sire/compare/2024.3.0...2024.3.1>`__ - December 2024
--------------------------------------------------------------------------------------------

Expand Down
8 changes: 8 additions & 0 deletions tests/cas/test_lambdaschedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,11 @@ def test_lambdaschedule():
)

_assert_same_equation(l.lam(), l.get_equation(stage="scale_up"), morph5_equation)

@pytest.mark.parametrize("force, lever, contained", [
("ghost-14", "kappa", True),
("ghost-14", "epsilon", True)
])
def test_has_force_specific_equation(force, lever, contained):
l = sr.cas.LambdaSchedule.standard_decouple()
assert l.has_force_specific_equation("decouple", force, lever) == contained

0 comments on commit b3a566b

Please sign in to comment.