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