1
1
#
2
2
# Tests the Interpreter class bindings
3
3
#
4
+ import math
4
5
import unittest
5
6
6
7
@@ -12,6 +13,15 @@ def test_create_destroy(self):
12
13
x = Interpreter ()
13
14
del x
14
15
16
+ def assert_array_equal (self , expected_values , values ):
17
+ self .assertEqual (len (expected_values ), len (values ))
18
+
19
+ for i in range (len (expected_values )):
20
+ if math .isnan (expected_values [i ]):
21
+ self .assertTrue (math .isnan (values [i ]))
22
+ else :
23
+ self .assertEqual (expected_values [i ], values [i ])
24
+
15
25
def test_hodgkin_huxley_squid_axon_model_1952 (self ):
16
26
from libcellml import Analyser
17
27
from libcellml import AnalyserModel
@@ -39,15 +49,19 @@ def test_hodgkin_huxley_squid_axon_model_1952(self):
39
49
40
50
self .assertEqual (0.0 , i .voi ())
41
51
42
- self .assertEqual ( 4 , len ( i .states () ))
43
- self .assertEqual ( 4 , len ( i .rates () ))
44
- self .assertEqual ( 18 , len ( i .variables () ))
52
+ self .assert_array_equal ([ math . nan , math . nan , math . nan , math . nan ], i .states ())
53
+ self .assert_array_equal ([ math . nan , math . nan , math . nan , math . nan ], i .rates ())
54
+ self .assert_array_equal ([ math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan , math . nan ], i .variables ())
45
55
46
56
i .initialiseVariables ()
47
57
i .computeComputedConstants ()
48
58
i .computeRates ()
49
59
i .computeVariables ()
50
60
61
+ self .assert_array_equal ([math .nan , math .nan , math .nan , math .nan ], i .states ())
62
+ self .assert_array_equal ([math .nan , math .nan , math .nan , math .nan ], i .rates ())
63
+ self .assert_array_equal ([math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan , math .nan ], i .variables ())
64
+
51
65
52
66
if __name__ == '__main__' :
53
67
unittest .main ()
0 commit comments