Skip to content

Commit

Permalink
- add test for constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergmann committed Oct 18, 2024
1 parent 5b4ee8f commit 19a3128
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions basico/task_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def set_opt_parameters(opt_parameters, model=None):
logger.warning('object {0} not found'.format(name))
continue

opt_item = problem.addOptItem(cn)
opt_item = problem.addOptItem(COPASI.CRegisteredCommonName(cn))
assert (isinstance(opt_item, COPASI.COptItem))
if 'lower' in item:
opt_item.setLowerBound(COPASI.CRegisteredCommonName(str(item['lower'])))
Expand Down Expand Up @@ -249,7 +249,7 @@ def set_opt_constraints(opt_constraints, model=None):
logger.warning('object {0} not found'.format(name))
continue

opt_item = problem.addOptConstraint(cn)
opt_item = problem.addOptConstraint(COPASI.CRegisteredCommonName(cn))
assert (isinstance(opt_item, COPASI.COptItem))
if 'lower' in item:
opt_item.setLowerBound(COPASI.CRegisteredCommonName(str(item['lower'])))
Expand Down
4 changes: 4 additions & 0 deletions tests/test_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def test_optitems(self):
items = basico.get_opt_parameters()
self.assertIsNotNone(items)

basico.set_opt_constraints(items)
items = basico.get_opt_constraints()
self.assertIsNotNone(items)

def test_settings(self):
settings = basico.get_opt_settings()
self.assertIsNotNone(settings)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_timecourse.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ def test_custom_output(self):
self.assertIsNotNone(tc)
self.assertListEqual(tc.columns.to_list(), ['Time', '[S1]', '[S2]', 'Values[k1]'])

def test_values(self):
tc = basico.run_time_course(values=[10, 20, 30])
tc2 = basico.run_time_course(values=[10, 20, 30], start_time=10)
self.assertIsNotNone(tc)
self.assertEqual(tc.shape, (4, 1))
self.assertEqual(tc2.shape, (3, 1))


def test_stochastic(self):
basico.new_model(name='Simple Model')
basico.add_reaction('R1', 'A ->')
Expand Down

0 comments on commit 19a3128

Please sign in to comment.