Skip to content

Commit

Permalink
Fix RDataReporting::observables_likelihood
Browse files Browse the repository at this point in the history
Fixes #2627. ReturnData.sllh was always NaN because it wasn't 0-initialized.
  • Loading branch information
dweindl committed Dec 19, 2024
1 parent 1716181 commit 326cbac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/tests/test_swig_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,9 @@ def test_reporting_mode_obs_llh(sbml_example_presimulation_module):
assert rdata.sy.size > 0
assert rdata.ssigmay.size > 0
assert rdata.sllh.size > 0
assert not np.isnan(rdata.sllh).any()
case amici.SensitivityMethod.adjoint:
assert rdata.sy is None
assert rdata.ssigmay is None
assert rdata.sllh.size > 0
assert not np.isnan(rdata.sllh).any()
1 change: 1 addition & 0 deletions src/rdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ void ReturnData::applyChainRuleFactorToSimulationResults(Model const& model) {

void ReturnData::initializeObjectiveFunction(bool enable_chi2) {
if (rdata_reporting == RDataReporting::likelihood
|| rdata_reporting == RDataReporting::observables_likelihood
|| rdata_reporting == RDataReporting::full) {
llh = 0.0;
std::fill(sllh.begin(), sllh.end(), 0.0);
Expand Down

0 comments on commit 326cbac

Please sign in to comment.