Skip to content

Commit

Permalink
fix: fixed recording time courses with initial time != 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrkarr committed Aug 10, 2021
1 parent 7838c6e commit 41303d9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Base OS
FROM python:3.9-slim-buster

ARG VERSION="0.1.27"
ARG VERSION="0.1.28"
ARG SIMULATOR_VERSION=4.33.246

# metadata
Expand Down
2 changes: 1 addition & 1 deletion biosimulators_copasi/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.27'
__version__ = '0.1.28'
6 changes: 2 additions & 4 deletions biosimulators_copasi/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ def exec_sed_task(task, variables, log=None):

copasi_problem = copasi_task.getProblem()
copasi_model.setInitialTime(sim.initial_time)
copasi_problem.setOutputStartTime(sim.output_start_time - sim.initial_time)
copasi_model.forceCompile()
copasi_problem.setOutputStartTime(sim.output_start_time)
copasi_problem.setDuration(sim.output_end_time - sim.initial_time)
if sim.output_end_time == sim.output_start_time:
if sim.output_start_time == sim.initial_time:
Expand Down Expand Up @@ -263,9 +264,6 @@ def exec_sed_task(task, variables, log=None):
for i_step in range(number_of_recorded_points):
step_values = copasi_data_handler.getNthRow(i_step)
for variable, value in zip(variables, step_values):
if variable.symbol == Symbol.time.value:
value += sim.initial_time

variable_results[variable.id][i_step] = value

if sim.output_end_time == sim.output_start_time and sim.output_start_time == sim.initial_time:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_core_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def test_exec_sed_task_correct_time_course_attrs(self):
task=task),
]

# initial time == 0, output start time == initial time
task.simulation.initial_time = 0.
task.simulation.output_start_time = 0.
task.simulation.output_end_time = 20.
Expand All @@ -217,6 +218,7 @@ def test_exec_sed_task_correct_time_course_attrs(self):
numpy.linspace(task.simulation.output_start_time, task.simulation.output_end_time, task.simulation.number_of_points + 1),
rtol=1e-4)

# initial time == 0, output start time != initial time
task.simulation.initial_time = 0.
task.simulation.output_start_time = 10.
task.simulation.output_end_time = 20.
Expand All @@ -228,6 +230,7 @@ def test_exec_sed_task_correct_time_course_attrs(self):
rtol=1e-4)
numpy.testing.assert_allclose(second_half_variable_results['A'], full_variable_results['A'][10:], rtol=1e-4)

# initial time != 0, output start time == initial time
task.simulation.initial_time = 5.
task.simulation.output_start_time = 5.
task.simulation.output_end_time = 25.
Expand All @@ -239,6 +242,7 @@ def test_exec_sed_task_correct_time_course_attrs(self):
rtol=1e-4)
numpy.testing.assert_allclose(offset_full_variable_results['A'], full_variable_results['A'], rtol=1e-4)

# initial time != 0, output start time != initial time
task.simulation.initial_time = 5.
task.simulation.output_start_time = 15.
task.simulation.output_end_time = 25.
Expand Down

0 comments on commit 41303d9

Please sign in to comment.