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 generic_fns import align_tensor
25 from prompt.interpreter import Interpreter
26 from relax_errors import RelaxError, RelaxBoolError, RelaxFloatError, RelaxIntError, RelaxNoneListStrError, RelaxNoneStrError, RelaxTupleNumError, RelaxStrError
27 from test_suite.unit_tests.align_tensor_testing_base import Align_tensor_base_class
28
29
30 from data_types import DATA_TYPES
31
32
34 """Unit tests for the functions of the 'prompt.align_tensor' module."""
35
49
50
52 """Failure of the tensor_from arg of the align_tensor.copy() user function."""
53
54
55 for data in DATA_TYPES:
56
57 if data[0] == 'str':
58 continue
59
60
61 self.assertRaises(RelaxStrError, self.align_tensor_fns.copy, tensor_from=data[1])
62
63
65 """The pipe_from arg test of the align_tensor.copy() user function."""
66
67
68 for data in DATA_TYPES:
69
70 if data[0] == 'None' or data[0] == 'str':
71 continue
72
73
74 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.copy, tensor_from='Pf1', pipe_from=data[1])
75
76
78 """Failure of the tensor_to arg of the align_tensor.copy() user function."""
79
80
81 for data in DATA_TYPES:
82
83 if data[0] == 'str':
84 continue
85
86
87 self.assertRaises(RelaxStrError, self.align_tensor_fns.copy, tensor_to=data[1])
88
89
91 """The pipe_to arg test of the align_tensor.copy() user function."""
92
93
94 for data in DATA_TYPES:
95
96 if data[0] == 'None' or data[0] == 'str':
97 continue
98
99
100 self.assertRaises(RelaxNoneStrError, self.align_tensor_fns.copy, tensor_from='Pf1', tensor_to='Pf1', pipe_to=data[1])
101
102
104 """The pipe_from and pipe_to arg test of the align_tensor.copy() user function."""
105
106
107 self.assertRaises(RelaxError, self.align_tensor_fns.copy, tensor_from='Pf1', tensor_to='Pf1')
108
109
121
122
134
135
137 """Failure of the tensor arg of the align_tensor.init() user function."""
138
139
140 for data in DATA_TYPES:
141
142 if data[0] == 'str':
143 continue
144
145
146 self.assertRaises(RelaxStrError, self.align_tensor_fns.init, tensor=data[1])
147
148
150 """Failure of the params arg of the align_tensor.init() user function."""
151
152
153 for data in DATA_TYPES:
154
155 if data[0] == 'tuple' or data[0] == 'float tuple' or data[0] == 'str tuple':
156
157 if len(data[1]) == 5:
158 continue
159
160
161 self.assertRaises(RelaxTupleNumError, self.align_tensor_fns.init, tensor='Pf1', params=data[1])
162
163
165 """The scale arg test of the align_tensor.init() user function."""
166
167
168 for data in DATA_TYPES:
169
170 if data[0] == 'float':
171 continue
172
173
174 self.assertRaises(RelaxFloatError, self.align_tensor_fns.init, tensor='Pf1', params=(0.0, 0.0, 0.0, 0.0, 0.0), scale=data[1])
175
176
178 """The angle_units arg test of the align_tensor.init() user function."""
179
180
181 for data in DATA_TYPES:
182
183 if data[0] == 'str':
184 continue
185
186
187 self.assertRaises(RelaxStrError, self.align_tensor_fns.init, params=(0.0, 0.0, 0.0, 0.0, 0.0), angle_units=data[1])
188
189
191 """The proper failure of the align_tensor.init() user function for the param_types argument."""
192
193
194 for data in DATA_TYPES:
195
196 if data[0] == 'int' or data[0] == 'bin':
197 continue
198
199
200 self.assertRaises(RelaxIntError, self.align_tensor_fns.init, tensor='Pf1', params=(0.0, 0.0, 0.0, 0.0, 0.0), param_types=data[1])
201
202
214
215
217 """The proper failure of the align_tensor.matrix_angles() user function for the basis_set argument."""
218
219
220 align_tensor.init('a', (0.0, 0.0, 0.0, 0.0, 0.0))
221
222
223 for data in DATA_TYPES:
224
225 if data[0] == 'int' or data[0] == 'bin':
226 continue
227
228
229 self.assertRaises(RelaxIntError, self.align_tensor_fns.matrix_angles, basis_set=data[1])
230
231
246
247
249 """Failure of the full_tensor arg of the align_tensor.reduction() user function."""
250
251
252 for data in DATA_TYPES:
253
254 if data[0] == 'str':
255 continue
256
257
258 self.assertRaises(RelaxStrError, self.align_tensor_fns.reduction, full_tensor=data[1])
259
260
262 """Failure of the red_tensor arg of the align_tensor.reduction() user function."""
263
264
265 for data in DATA_TYPES:
266
267 if data[0] == 'str':
268 continue
269
270
271 self.assertRaises(RelaxStrError, self.align_tensor_fns.reduction, full_tensor='test', red_tensor=data[1])
272
274 """Failure of the tensor arg of the align_tensor.set_domain() user function."""
275
276
277 for data in DATA_TYPES:
278
279 if data[0] == 'str':
280 continue
281
282
283 self.assertRaises(RelaxStrError, self.align_tensor_fns.set_domain, tensor=data[1])
284
285
287 """Failure of the domain arg of the align_tensor.set_domain() user function."""
288
289
290 for data in DATA_TYPES:
291
292 if data[0] == 'str':
293 continue
294
295
296 self.assertRaises(RelaxStrError, self.align_tensor_fns.set_domain, domain=data[1])
297
298
300 """The proper failure of the align_tensor.svd() user function for the basis_set argument."""
301
302
303 align_tensor.init('a', (0.0, 0.0, 0.0, 0.0, 0.0))
304
305
306 for data in DATA_TYPES:
307
308 if data[0] == 'int' or data[0] == 'bin':
309 continue
310
311
312 self.assertRaises(RelaxIntError, self.align_tensor_fns.svd, basis_set=data[1])
313
314
316 """The tensors arg unit test of the align_tensor.svd() user function."""
317
318
319 align_tensor.init('a', (0.0, 0.0, 0.0, 0.0, 0.0))
320
321
322 for data in DATA_TYPES:
323
324 if data[0] == 'None' or data[0] == 'str list':
325 continue
326
327
328 self.assertRaises(RelaxNoneListStrError, self.align_tensor_fns.svd, tensors=data[1])
329