Skip to content

Commit

Permalink
Merge pull request #16 from biosimulators/fix-initial-vs-output-diff
Browse files Browse the repository at this point in the history
Fix situation when the output start time is different from the initia…
  • Loading branch information
luciansmith committed Aug 3, 2023
2 parents 96ce780 + 036e516 commit f555e25
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
2 changes: 1 addition & 1 deletion biosimulators_tellurium/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.37'
__version__ = '0.1.38'
22 changes: 8 additions & 14 deletions biosimulators_tellurium/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,14 @@ def exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None

# simulate
if isinstance(sim, UniformTimeCourseSimulation):
number_of_points = (sim.output_end_time - sim.initial_time) / \
(sim.output_end_time - sim.output_start_time) * sim.number_of_steps + 1
if abs(number_of_points % 1) > 1e-8:
msg = (
'The number of simulation points `{}` must be an integer:'
'\n Initial time: {}'
'\n Output start time: {}'
'\n Output end time: {}'
'\n Number of points: {}'
).format(number_of_points, sim.initial_time, sim.output_start_time, sim.output_start_time, sim.number_of_points)
raise NotImplementedError(msg)

number_of_points = round(number_of_points)
results = numpy.array(road_runner.simulate(sim.initial_time, sim.output_end_time, number_of_points).tolist()).transpose()
if sim.initial_time < sim.output_start_time:
number_of_presim_points = (sim.output_end_time - sim.initial_time) / \
(sim.output_end_time - sim.output_start_time) * sim.number_of_steps + 1

number_of_presim_points = round(number_of_presim_points) - sim.number_of_steps
road_runner.simulate(sim.initial_time, sim.output_start_time, number_of_presim_points)

results = numpy.array(road_runner.simulate(sim.output_start_time, sim.output_end_time, sim.number_of_steps+1).tolist()).transpose()
else:
road_runner.steadyState()
results = road_runner.getSteadyStateValues()
Expand Down
6 changes: 0 additions & 6 deletions tests/test_core_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,6 @@ def test_exec_sed_task_error_handling_with_biosimulators(self):
with self.assertRaisesRegex(ValueError, 'targets are not supported'):
variable_results, log = core.exec_sed_task(task, variables_2, simulator_config=simulator_config)

task_2 = copy.deepcopy(task)
task_2.simulation.output_start_time = 1.5
simulator_config.sedml_interpreter = SedmlInterpreter.biosimulators
with self.assertRaises(NotImplementedError):
variable_results, log = core.exec_sed_task(task_2, variables, simulator_config=simulator_config)

def test_exec_sed_task_with_preprocesssed_task(self):
# configure simulation
task = sedml_data_model.Task(
Expand Down

0 comments on commit f555e25

Please sign in to comment.