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