1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23  from pipe_control import align_tensor 
 24  from prompt.interpreter import Interpreter 
 25  from lib.errors import RelaxError, RelaxBoolError, RelaxFloatError, RelaxIntError, RelaxListStrError, 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] == 'None' or 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(RelaxStrError, 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] == 'None' or  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(RelaxStrError, 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   
110          """Failure of the tensor arg of the align_tensor.delete() user function.""" 
111   
112           
113          for data in DATA_TYPES: 
114               
115              if data[0] == 'None' or data[0] == 'str': 
116                  continue 
117   
118               
119              self.assertRaises(RelaxStrError, self.align_tensor_fns.delete, tensor=data[1]) 
 120   
121   
123          """Failure of the tensor arg of the align_tensor.display() user function.""" 
124   
125           
126          for data in DATA_TYPES: 
127               
128              if data[0] == 'None' or data[0] == 'str': 
129                  continue 
130   
131               
132              self.assertRaises(RelaxStrError, self.align_tensor_fns.display, tensor=data[1]) 
 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] == 'None' or 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 align_id arg of the align_tensor.init() user function.""" 
150   
151           
152          for data in DATA_TYPES: 
153               
154              if data[0] == 'str': 
155                  continue 
156   
157               
158              self.assertRaises(RelaxStrError, self.align_tensor_fns.init, align_id=data[1]) 
 159   
160   
162          """Failure of the domain arg of the align_tensor.init() user function.""" 
163   
164           
165          for data in DATA_TYPES: 
166               
167              if data[0] == 'None' or data[0] == 'str': 
168                  continue 
169   
170               
171              self.assertRaises(RelaxStrError, self.align_tensor_fns.init, align_id='Pf1', domain=data[1]) 
 172   
173   
175          """Failure of the params arg of the align_tensor.init() user function.""" 
176   
177           
178          for data in DATA_TYPES: 
179               
180              if data[0] == 'None' or data[0] == 'tuple' or data[0] == 'float tuple' or data[0] == 'str tuple': 
181                   
182                  if data[0] == 'None' or len(data[1]) == 5: 
183                      continue 
184   
185               
186              self.assertRaises(RelaxTupleNumError, self.align_tensor_fns.init, align_id='Pf1', params=data[1]) 
 187   
188   
190          """The scale arg test of the align_tensor.init() user function.""" 
191   
192           
193          for data in DATA_TYPES: 
194               
195              if data[0] == 'float': 
196                  continue 
197   
198               
199              self.assertRaises(RelaxFloatError, self.align_tensor_fns.init, align_id='Pf1', params=(0.0, 0.0, 0.0, 0.0, 0.0), scale=data[1]) 
 200   
201   
203          """The angle_units arg test of the align_tensor.init() user function.""" 
204   
205           
206          for data in DATA_TYPES: 
207               
208              if data[0] == 'str': 
209                  continue 
210   
211               
212              self.assertRaises(RelaxStrError, self.align_tensor_fns.init, params=(0.0, 0.0, 0.0, 0.0, 0.0), angle_units=data[1]) 
 213   
214   
216          """The proper failure of the align_tensor.init() user function for the param_types argument.""" 
217   
218           
219          for data in DATA_TYPES: 
220               
221              if data[0] == 'int' or data[0] == 'bin': 
222                  continue 
223   
224               
225              self.assertRaises(RelaxIntError, self.align_tensor_fns.init, align_id='Pf1', params=(0.0, 0.0, 0.0, 0.0, 0.0), param_types=data[1]) 
 226   
227   
229          """The errors arg test of the align_tensor.init() user function.""" 
230   
231           
232          for data in DATA_TYPES: 
233               
234              if data[0] == 'bool': 
235                  continue 
236   
237               
238              self.assertRaises(RelaxBoolError, self.align_tensor_fns.init, align_id='Pf1', params=(0.0, 0.0, 0.0, 0.0, 0.0), errors=data[1]) 
 239   
240   
242          """The proper failure of the align_tensor.matrix_angles() user function for the basis_set argument.""" 
243   
244           
245          align_tensor.init(align_id='a', params=(0.0, 0.0, 0.0, 0.0, 0.0)) 
246   
247           
248          for data in DATA_TYPES: 
249               
250              if data[0] == 'str': 
251                  continue 
252   
253               
254              self.assertRaises(RelaxStrError, self.align_tensor_fns.matrix_angles, basis_set=data[1]) 
 255   
256   
271   
272   
274          """Failure of the full_tensor arg of the align_tensor.reduction() 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.reduction, full_tensor=data[1]) 
 284   
285   
287          """Failure of the red_tensor arg of the align_tensor.reduction() 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.reduction, full_tensor='test', red_tensor=data[1]) 
 297   
299          """Failure of the tensor arg of the align_tensor.set_domain() user function.""" 
300   
301           
302          for data in DATA_TYPES: 
303               
304              if data[0] == 'str': 
305                  continue 
306   
307               
308              self.assertRaises(RelaxStrError, self.align_tensor_fns.set_domain, tensor=data[1]) 
 309   
310   
312          """Failure of the domain arg of the align_tensor.set_domain() user function.""" 
313   
314           
315          for data in DATA_TYPES: 
316               
317              if data[0] == 'str': 
318                  continue 
319   
320               
321              self.assertRaises(RelaxStrError, self.align_tensor_fns.set_domain, domain=data[1]) 
 322   
323   
325          """The proper failure of the align_tensor.svd() user function for the basis_set argument.""" 
326   
327           
328          align_tensor.init(align_id='a', params=(0.0, 0.0, 0.0, 0.0, 0.0)) 
329   
330           
331          for data in DATA_TYPES: 
332               
333              if data[0] == 'str': 
334                  continue 
335   
336               
337              self.assertRaises(RelaxStrError, self.align_tensor_fns.svd, basis_set=data[1]) 
 338   
339   
341          """The tensors arg unit test of the align_tensor.svd() user function.""" 
342   
343           
344          align_tensor.init(align_id='a', params=(0.0, 0.0, 0.0, 0.0, 0.0)) 
345   
346           
347          for data in DATA_TYPES: 
348               
349              if data[0] == 'None' or data[0] == 'str list': 
350                  continue 
351   
352               
353              self.assertRaises(RelaxListStrError, self.align_tensor_fns.svd, tensors=data[1]) 
  354