From 92a530b07d39bb52611fe62844438b71a2febab6 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Thu, 19 Dec 2024 21:07:15 +0100 Subject: [PATCH] Fix RDataReporting::observables_likelihood (#2633) Fixes #2627. ReturnData.sllh was always NaN because it wasn't 0-initialized. --- python/tests/test_swig_interface.py | 2 ++ src/rdata.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/python/tests/test_swig_interface.py b/python/tests/test_swig_interface.py index 4ead568c9c..217a9ad5b7 100644 --- a/python/tests/test_swig_interface.py +++ b/python/tests/test_swig_interface.py @@ -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() diff --git a/src/rdata.cpp b/src/rdata.cpp index c724d29954..460e9bd674 100644 --- a/src/rdata.cpp +++ b/src/rdata.cpp @@ -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);