forked from copasi/basico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sensitivities.py
64 lines (53 loc) · 2.79 KB
/
test_sensitivities.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import unittest
import basico
class TestSensitivities(unittest.TestCase):
def setUp(self):
basico.load_example('bruss')
self.assertIsNotNone(basico.get_species('X', exact=True))
def test_settings(self):
settings = basico.get_sensitivity_settings()
self.assertDictEqual(settings,
{
'scheduled': False,
'update_model': False,
'method': {'Delta factor': 0.001,
'Delta minimum': 1e-12,
'name': 'Sensitivities Method'},
'report': {'filename': '',
'report_definition': 'Sensitivities',
'append': True,
'confirm_overwrite': False},
'sub_task': 'Steady State',
'effect': 'Non-Constant Concentrations of Species',
'cause': 'All Parameter Values',
'secondary_cause': 'Not Set'
})
basico.set_sensitivity_settings({
'effect': basico.SENS.METAB_CONCENTRATIONS,
'cause': basico.SENS.METAB_INITIAL_CONCENTRATIONS,
'scheduled': True
})
settings = basico.get_sensitivity_settings()
self.assertEqual(settings['scheduled'], True)
self.assertEqual(settings['effect'], basico.SENS.METAB_CONCENTRATIONS)
self.assertEqual(settings['cause'], basico.SENS.METAB_INITIAL_CONCENTRATIONS)
def test_enums(self):
self.assertEqual(basico.SENS.from_enum(1), basico.SENS.SINGLE_OBJECT)
self.assertEqual(basico.SENS.to_enum(basico.SENS.SINGLE_OBJECT), 1)
self.assertEqual(basico.SENS_ST.to_enum(basico.SENS_ST.Evaluation), 0)
self.assertEqual(basico.SENS_ST.to_enum(basico.SENS_ST.SteadyState), 1)
self.assertEqual(basico.SENS_ST.to_enum(basico.SENS_ST.TimeSeries), 2)
self.assertEqual(basico.SENS_ST.to_enum(basico.T.TIME_COURSE), 2)
self.assertEqual(basico.SENS_ST.to_enum(basico.T.TIME_COURSE),
basico.SENS_ST.to_enum(basico.SENS_ST.TimeSeries))
self.assertEqual(basico.SENS.from_enum(3), basico.SENS.METAB_INITIAL_CONCENTRATIONS)
def test_run(self):
basico.run_sensitivities()
scaled = basico.get_scaled_sensitivities()
self.assertIsNotNone(scaled)
unscaled = basico.get_unscaled_sensitivities()
self.assertIsNotNone(unscaled)
summarized = basico.get_summarized_sensitivities()
self.assertIsNotNone(summarized)
if __name__ == '__main__':
unittest.main()