1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 from unittest import TestCase
25
26
27 from generic_fns import pipes, value
28 from test_suite.unit_tests.value_testing_base import Value_base_class
29
30
31
33 """Unit tests for the functions of the 'generic_fns.value' module."""
34
35
36 value_fns = value
37
38
40 """First test of the generic_fns.value.partition_params() function."""
41
42
43 pipes.switch('mf')
44
45
46 param = ['s2']
47 val = [0.8]
48
49
50 spin_params, spin_values, other_params, other_values = value.partition_params(val, param)
51
52
53 self.assertEqual(spin_params, ['s2'])
54 self.assertEqual(spin_values, [0.8])
55 self.assertEqual(other_params, [])
56 self.assertEqual(other_values, [])
57
58
60 """Second test of the generic_fns.value.partition_params() function."""
61
62
63 pipes.switch('mf')
64
65
66 param = ['Dx']
67 val = [1e7]
68
69
70 spin_params, spin_values, other_params, other_values = value.partition_params(val, param)
71
72
73 self.assertEqual(spin_params, [])
74 self.assertEqual(spin_values, [])
75 self.assertEqual(other_params, ['Dx'])
76 self.assertEqual(other_values, [1e7])
77
78
80 """Third test of the generic_fns.value.partition_params() function."""
81
82
83 pipes.switch('mf')
84
85
86 param = ['Dx', 's2']
87 val = [1e7, 0.8]
88
89
90 spin_params, spin_values, other_params, other_values = value.partition_params(val, param)
91
92
93 self.assertEqual(spin_params, ['s2'])
94 self.assertEqual(spin_values, [0.8])
95 self.assertEqual(other_params, ['Dx'])
96 self.assertEqual(other_values, [1e7])
97
98
100 """Forth test of the generic_fns.value.partition_params() function."""
101
102
103 pipes.switch('mf')
104
105
106 param = ['Dx', 's2', 'csa']
107 val = [1e7, 0.8, -160e-6]
108
109
110 spin_params, spin_values, other_params, other_values = value.partition_params(val, param)
111
112
113 self.assertEqual(spin_params, ['s2', 'csa'])
114 self.assertEqual(spin_values, [0.8, -160e-6])
115 self.assertEqual(other_params, ['Dx'])
116 self.assertEqual(other_values, [1e7])
117
118
120 """Fifth test of the generic_fns.value.partition_params() function."""
121
122
123 pipes.switch('mf')
124
125
126 param = ['Dpar', 's2', 'Dper', 'csa', 'theta']
127 val = [1e7, 0.8, 2e7, -160e-6, 0.13]
128
129
130 spin_params, spin_values, other_params, other_values = value.partition_params(val, param)
131
132
133 self.assertEqual(spin_params, ['s2', 'csa'])
134 self.assertEqual(spin_values, [0.8, -160e-6])
135 self.assertEqual(other_params, ['Dpar', 'Dper', 'theta'])
136 self.assertEqual(other_values, [1e7, 2e7, 0.13])
137
138
140 """Sixth test of the generic_fns.value.partition_params() function."""
141
142
143 pipes.switch('mf')
144
145
146 param = []
147 val = []
148
149
150 spin_params, spin_values, other_params, other_values = value.partition_params(val, param)
151
152
153 self.assertEqual(spin_params, [])
154 self.assertEqual(spin_values, [])
155 self.assertEqual(other_params, [])
156 self.assertEqual(other_values, [])
157