Skip to content

Commit

Permalink
- performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergmann committed Dec 20, 2022
1 parent 7a31e79 commit 63b62aa
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 167 deletions.
396 changes: 232 additions & 164 deletions basico/model_info.py

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions basico/task_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ def run_optimization(expression=None, output=None, settings=None, **kwargs):
"""
model = model_io.get_model_from_dict_or_default(kwargs)

model.getModel().compileIfNecessary()

task = model.getTask(basico.T.OPTIMIZATION)
assert (isinstance(task, COPASI.COptTask))
problem = task.getProblem()
Expand Down
2 changes: 2 additions & 0 deletions basico/task_parameterestimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@ def run_parameter_estimation(**kwargs):
model = model_io.get_model_from_dict_or_default(kwargs)
assert (isinstance(model, COPASI.CDataModel))

model.getModel().compileIfNecessary()

task = model.getTask(TASK_PARAMETER_ESTIMATION)
assert (isinstance(task, COPASI.CFitTask))

Expand Down
2 changes: 2 additions & 0 deletions basico/task_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ def run_scan(**kwargs):
"""
model = model_io.get_model_from_dict_or_default(kwargs)

model.getModel().compileIfNecessary()

if 'settings' in kwargs:
set_scan_settings(settings=kwargs['settings'], model=model)

Expand Down
2 changes: 2 additions & 0 deletions basico/task_sensitivities.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ def run_sensitivities(**kwargs):
model = model_io.get_model_from_dict_or_default(kwargs)
assert (isinstance(model, COPASI.CDataModel))

model.getModel().compileIfNecessary()

if 'settings' in kwargs:
basico.set_sensitivity_settings(kwargs['settings'], model=model)

Expand Down
2 changes: 2 additions & 0 deletions basico/task_steadystate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def run_steadystate(**kwargs):
model = model_io.get_model_from_dict_or_default(kwargs)
assert (isinstance(model, COPASI.CDataModel))

model.getModel().compileIfNecessary()

task = model.getTask('Steady-State')
assert (isinstance(task, COPASI.CSteadyStateTask))

Expand Down
5 changes: 5 additions & 0 deletions basico/task_timecourse.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def run_time_course_with_output(output_selection, *args, **kwargs):
"""
model = model_io.get_model_from_dict_or_default(kwargs)

model.getModel().compileIfNecessary()

dh, columns = create_data_handler(output_selection, model=model)

task, use_initial_values = _setup_timecourse(args, kwargs)
Expand Down Expand Up @@ -308,6 +311,8 @@ def run_time_course(*args, **kwargs):
"""
model = model_io.get_model_from_dict_or_default(kwargs)

model.getModel().compileIfNecessary()

task, use_initial_values = _setup_timecourse(args, kwargs)

result = task.initializeRaw(COPASI.CCopasiTask.OUTPUT_UI)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_basico_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
class TestBasicoIO_Brus(unittest.TestCase):

def setUp(self):
dm = basico.load_example('brusselator')
self.assertTrue(dm is not None)
self.assertTrue(isinstance(dm, COPASI.CDataModel))
self.dm = basico.load_example('brusselator')
self.assertTrue(self.dm is not None)
self.assertTrue(isinstance(self.dm, COPASI.CDataModel))
self.assertTrue('The Brusselator' in basico.model_io.overview())

def test_get_species(self):
Expand Down

0 comments on commit 63b62aa

Please sign in to comment.