Skip to content

Commit f555e25

Browse files
authored
Merge pull request #16 from biosimulators/fix-initial-vs-output-diff
Fix situation when the output start time is different from the initia…
2 parents 96ce780 + 036e516 commit f555e25

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

biosimulators_tellurium/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.1.37'
1+
__version__ = '0.1.38'

biosimulators_tellurium/core.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -263,20 +263,14 @@ def exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None
263263

264264
# simulate
265265
if isinstance(sim, UniformTimeCourseSimulation):
266-
number_of_points = (sim.output_end_time - sim.initial_time) / \
267-
(sim.output_end_time - sim.output_start_time) * sim.number_of_steps + 1
268-
if abs(number_of_points % 1) > 1e-8:
269-
msg = (
270-
'The number of simulation points `{}` must be an integer:'
271-
'\n Initial time: {}'
272-
'\n Output start time: {}'
273-
'\n Output end time: {}'
274-
'\n Number of points: {}'
275-
).format(number_of_points, sim.initial_time, sim.output_start_time, sim.output_start_time, sim.number_of_points)
276-
raise NotImplementedError(msg)
277-
278-
number_of_points = round(number_of_points)
279-
results = numpy.array(road_runner.simulate(sim.initial_time, sim.output_end_time, number_of_points).tolist()).transpose()
266+
if sim.initial_time < sim.output_start_time:
267+
number_of_presim_points = (sim.output_end_time - sim.initial_time) / \
268+
(sim.output_end_time - sim.output_start_time) * sim.number_of_steps + 1
269+
270+
number_of_presim_points = round(number_of_presim_points) - sim.number_of_steps
271+
road_runner.simulate(sim.initial_time, sim.output_start_time, number_of_presim_points)
272+
273+
results = numpy.array(road_runner.simulate(sim.output_start_time, sim.output_end_time, sim.number_of_steps+1).tolist()).transpose()
280274
else:
281275
road_runner.steadyState()
282276
results = road_runner.getSteadyStateValues()

tests/test_core_main.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,6 @@ def test_exec_sed_task_error_handling_with_biosimulators(self):
436436
with self.assertRaisesRegex(ValueError, 'targets are not supported'):
437437
variable_results, log = core.exec_sed_task(task, variables_2, simulator_config=simulator_config)
438438

439-
task_2 = copy.deepcopy(task)
440-
task_2.simulation.output_start_time = 1.5
441-
simulator_config.sedml_interpreter = SedmlInterpreter.biosimulators
442-
with self.assertRaises(NotImplementedError):
443-
variable_results, log = core.exec_sed_task(task_2, variables, simulator_config=simulator_config)
444-
445439
def test_exec_sed_task_with_preprocesssed_task(self):
446440
# configure simulation
447441
task = sedml_data_model.Task(

0 commit comments

Comments
 (0)