From 8ae73aaa157fe0ab196a3a9b05e61b6d22835f03 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 4 Dec 2023 12:11:43 +0100 Subject: [PATCH] .. --- include/amici/serialization.h | 1 + matlab/@amimodel/generateC.m | 1 + python/tests/test_events.py | 19 +++++++------------ python/tests/test_swig_interface.py | 1 + 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/amici/serialization.h b/include/amici/serialization.h index 1f29961bcc..787a0e4bd5 100644 --- a/include/amici/serialization.h +++ b/include/amici/serialization.h @@ -143,6 +143,7 @@ void serialize(Archive& ar, amici::Model& m, unsigned int const /*version*/) { ar& m.sigma_res_; ar& m.steadystate_computation_mode_; ar& m.steadystate_sensitivity_mode_; + ar& m.state_independent_events_; } /** diff --git a/matlab/@amimodel/generateC.m b/matlab/@amimodel/generateC.m index 59eb5e37b4..869f386baf 100644 --- a/matlab/@amimodel/generateC.m +++ b/matlab/@amimodel/generateC.m @@ -163,6 +163,7 @@ function generateC(this) fprintf(fid,[' ' num2str(this.nz) ',\n']); fprintf(fid,[' ' num2str(this.nztrue) ',\n']); fprintf(fid,[' ' num2str(this.nevent) ',\n']); +fprintf(fid,[' ' num2str(this.nevent) ',\n']); fprintf(fid,[' 0,\n']); fprintf(fid,[' ' num2str(this.ng) ',\n']); fprintf(fid,[' ' num2str(this.nw) ',\n']); diff --git a/python/tests/test_events.py b/python/tests/test_events.py index 2e5b337a65..065cdeb126 100644 --- a/python/tests/test_events.py +++ b/python/tests/test_events.py @@ -1,8 +1,12 @@ """Tests for SBML events, including piecewise expressions.""" from copy import deepcopy +import amici import numpy as np import pytest +from amici.antimony_import import antimony2amici +from amici.gradient_check import check_derivatives +from amici.testing import TemporaryDirectoryWinSafe as TemporaryDirectory from amici.testing import skip_on_valgrind from util import ( check_trajectories_with_forward_sensitivities, @@ -706,17 +710,8 @@ def expm(x): return np.array(expm(x).tolist()).astype(float) -import amici -from amici.antimony_import import antimony2amici -from amici.gradient_check import check_derivatives -from amici.testing import TemporaryDirectoryWinSafe as TemporaryDirectory - - def test_handling_of_fixed_time_point_event_triggers(): - """If this example requires changes, please also update documentation/python_interface.rst.""" - import os - - os.environ["ENABLE_AMICI_DEBUGGING"] = "TRUE" + """Test handling of events without solver-tracked root functions.""" ant_model = """ model test_events_time_based event_target = 0 @@ -724,7 +719,6 @@ def test_handling_of_fixed_time_point_event_triggers(): at (time > 1): event_target = 1 at (time > 2): event_target = event_target + bolus at (time > 3): event_target = 3 - end """ module_name = "test_events_time_based" @@ -739,6 +733,8 @@ def test_handling_of_fixed_time_point_event_triggers(): module_name=module_name, module_path=outdir ) amici_model = model_module.getModel() + assert amici_model.ne == 3 + assert amici_model.ne_solver == 0 amici_model.setTimepoints(np.linspace(0, 4, 200)) amici_solver = amici_model.getSolver() rdata = amici.runAmiciSimulation(amici_model, amici_solver) @@ -748,5 +744,4 @@ def test_handling_of_fixed_time_point_event_triggers(): assert (rdata.x[(rdata.ts >= 2) & (rdata.ts < 3)] == 2).all() assert (rdata.x[(rdata.ts >= 3)] == 3).all() - # TODO sensitivities check_derivatives(amici_model, amici_solver, edata=None) diff --git a/python/tests/test_swig_interface.py b/python/tests/test_swig_interface.py index a746552b55..6a7cfec855 100644 --- a/python/tests/test_swig_interface.py +++ b/python/tests/test_swig_interface.py @@ -315,6 +315,7 @@ def test_unhandled_settings(pysb_example_presimulation_module): "setParametersByIdRegex", "setParametersByNameRegex", "setInitialStateSensitivities", + "get_trigger_timepoints", ] from amici.swig_wrappers import model_instance_settings