From dca59769134eae95ecef4d5ffebb2caea506e44d Mon Sep 17 00:00:00 2001 From: "Frank T. Bergmann" Date: Thu, 27 Jan 2022 11:43:03 +0100 Subject: [PATCH] - add some more tests --- tests/test_basico_info.py | 63 +++++++++++++++++++++++++++++++ tests/test_parameterestimation.py | 8 ++++ 2 files changed, 71 insertions(+) diff --git a/tests/test_basico_info.py b/tests/test_basico_info.py index 96976cd..aff0ce0 100644 --- a/tests/test_basico_info.py +++ b/tests/test_basico_info.py @@ -54,6 +54,69 @@ def test_expressions(self): result = basico.model_info._split_by_cn('sin(A + B + C)') self.assertTrue(len(result) == 8) + def test_notes(self): + notes = basico.model_info.get_notes() + self.assertTrue('The famous Brusselator' in notes) + basico.model_info.set_notes(""" + + New Multiline Comment + + """) + new_notes = basico.model_info.get_notes() + self.assertTrue('Multiline' in new_notes) + + metab_notes = basico.model_info.get_notes(name='[X]') + basico.model_info.set_notes('Notes on the species X', name='[X]') + new_metab_notes = basico.model_info.get_notes(name='[X]') + self.assertTrue('species X' in new_metab_notes) + + def test_events(self): + events = basico.model_info.get_events() + self.assertIsNone(events) + basico.add_event('e0', trigger='Time > 10', assignments=[('[X]', '10')]) + events = basico.get_events('e0').reset_index() + self.assertIsNotNone(events) + d = events.to_dict(orient='record')[0] + self.assertEqual(d['name'], 'e0') + self.assertEqual(d['trigger'], 'Time > 10') + self.assertEqual(d['assignments'][0]['target'], '[X]') + self.assertEqual(d['assignments'][0]['expression'], '10') + basico.model_info.add_event_assignment('e0', assignment=('[Y]', '2')) + events = basico.get_events('e0').reset_index() + d = events.to_dict(orient='record')[0] + self.assertEqual(len(d['assignments']), 2) + + def test_matrices(self): + jac = basico.model_info.get_jacobian_matrix(True) + self.assertIsNotNone(jac) + red = basico.model_info.get_reduced_jacobian_matrix() + self.assertIsNotNone(red) + stoich = basico.model_info.get_stoichiometry_matrix() + self.assertIsNotNone(stoich) + red_s = basico.model_info.get_reduced_stoichiometry_matrix() + self.assertIsNotNone(red_s) + + def test_new_getter(self): + tasks = basico.model_info.get_scheduled_tasks() + self.assertEqual(len(tasks), 0) + basico.set_scheduled_tasks(basico.T.TIME_COURSE) + tasks = basico.model_info.get_scheduled_tasks() + self.assertEqual(len(tasks), 1) + cn = basico.model_info.get_cn('[X]') + self.assertTrue('Metabolite' in cn) + val = basico.model_info.get_value('[X]') + self.assertIsNotNone(val) + + def test_amount(self): + params = basico.get_parameters(type='assignment') + self.assertIsNone(params) + basico.add_amount_expressions() + params2 = basico.get_parameters(type='assignment') + self.assertIsNotNone(params2) + basico.remove_amount_expressions() + param3 = basico.get_parameters(type='assignment') + self.assertIsNone(param3) + def test_get_plots(self): result = basico.model_info.get_plots() self.assertEqual(len(result), 3) diff --git a/tests/test_parameterestimation.py b/tests/test_parameterestimation.py index 9ad0eaa..e6f6089 100644 --- a/tests/test_parameterestimation.py +++ b/tests/test_parameterestimation.py @@ -57,6 +57,14 @@ def test_run(self): self.assertTrue(sol is not None) self.assertAlmostEqual(sol.loc['(R1).k2'].sol, 1.0, places=2) + def test_remove(self): + fit_items = basico.get_fit_parameters() + self.assertIsNotNone(fit_items) + basico.remove_fit_parameters() + fit_items_2 = basico.get_fit_parameters() + self.assertIsNone(fit_items_2) + basico.set_fit_parameters(fit_items) + class TestBasicoParamterEstimationPK(unittest.TestCase):