1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import traceback
25 import sys
26
27
28
29 from angles import Angles
30 from consistency_tests import Consistent
31 from diffusion_tensor import Diffusion_tensor
32 from generic import Generic
33 from jw_mapping import Jw
34 from model_free import Mf
35 from model_selection import Modsel
36 from relax_fit import Relax_fit
37 from run_create import Run_create
38 from sequence import Sequence
39
40
43 """The relax test suite.
44
45 This class runs a number of tests to determine if any changes to relax have caused
46 breakages.
47 """
48
49 self.relax = relax
50
51
52
53
54
55
56 self.heading("The relax test suite")
57
58
59
60
61
62
63 self.heading("The run tests")
64
65
66 self.run_test_array = []
67
68
69 self.run_test_array.append(Run_create(self.relax))
70
71
72 self.exec_tests(self.run_test_array)
73
74
75
76
77
78
79 self.heading("The sequence tests")
80
81
82 self.seq_test_array = []
83
84
85 self.seq_test_array.append(Sequence(self.relax, 'read'))
86
87
88 self.seq_test_array.append(Sequence(self.relax, 'pdb'))
89
90
91 self.exec_tests(self.seq_test_array)
92
93
94
95
96
97
98 self.heading("The diffusion tensor tests")
99
100
101 self.diff_tensor_test_array = []
102
103
104 self.diff_tensor_test_array.append(Diffusion_tensor(self.relax, 'init'))
105 self.diff_tensor_test_array.append(Diffusion_tensor(self.relax, 'delete'))
106 self.diff_tensor_test_array.append(Diffusion_tensor(self.relax, 'display'))
107 self.diff_tensor_test_array.append(Diffusion_tensor(self.relax, 'copy'))
108
109
110 self.exec_tests(self.diff_tensor_test_array)
111
112
113
114
115
116
117 self.heading("Angle calculation tests")
118
119
120 self.angles_test_array = []
121
122
123 self.angles_test_array.append(Angles(self.relax))
124
125
126 self.exec_tests(self.angles_test_array)
127
128
129
130
131
132
133 self.heading("The relaxation curve-fitting tests")
134
135
136 self.relax_fit_test_array = []
137
138
139 self.relax_fit_test_array.append(Relax_fit(self.relax, 'read_sparky'))
140
141
142 self.exec_tests(self.relax_fit_test_array)
143
144
145
146
147
148
149 self.heading("The model-free tests")
150
151
152 self.mf_test_array = []
153
154
155 self.mf_test_array.append(Mf(self.relax, 'read relaxation data'))
156 self.mf_test_array.append(Mf(self.relax, 'set csa'))
157 self.mf_test_array.append(Mf(self.relax, 'set bond length'))
158 self.mf_test_array.append(Mf(self.relax, 'set csa and bond length'))
159 self.mf_test_array.append(Mf(self.relax, 'select m4'))
160 self.mf_test_array.append(Mf(self.relax, 'create m4'))
161 self.mf_test_array.append(Mf(self.relax, 'read results'))
162 self.mf_test_array.append(Mf(self.relax, 'opendx {S2, te, Rex} map'))
163 self.mf_test_array.append(Mf(self.relax, 'opendx {theta, phi, Da} map'))
164 self.mf_test_array.append(Mf(self.relax, 'opendx {local_tm, S2, te} map'))
165 self.mf_test_array.append(Mf(self.relax, 'Constrained grid search {S2=0.970, te=2048, Rex=0.149}'))
166 self.mf_test_array.append(Mf(self.relax, 'Constrained SD, backtracking opt {S2=0.970, te=2048, Rex=0.149}'))
167 self.mf_test_array.append(Mf(self.relax, 'Constrained SD, MT opt {S2=0.970, te=2048, Rex=0.149}'))
168 self.mf_test_array.append(Mf(self.relax, 'Constrained CD, backtracking opt {S2=0.970, te=2048, Rex=0.149}'))
169 self.mf_test_array.append(Mf(self.relax, 'Constrained CD, MT opt {S2=0.970, te=2048, Rex=0.149}'))
170 self.mf_test_array.append(Mf(self.relax, 'Constrained BFGS, backtracking opt {S2=0.970, te=2048, Rex=0.149}'))
171 self.mf_test_array.append(Mf(self.relax, 'Constrained BFGS, backtracking opt {S2=0.970, te=2048, Rex=0.149}'))
172 self.mf_test_array.append(Mf(self.relax, 'Constrained Newton, GMW, backtracking opt {S2=0.970, te=2048, Rex=0.149}'))
173 self.mf_test_array.append(Mf(self.relax, 'Constrained Newton, GMW, MT opt {S2=0.970, te=2048, Rex=0.149}'))
174
175
176 self.exec_tests(self.mf_test_array)
177
178
179
180
181
182
183 self.heading("The reduced spectral density mapping tests")
184
185
186 self.jw_test_array = []
187
188
189 self.jw_test_array.append(Jw(self.relax, 'set'))
190 self.jw_test_array.append(Jw(self.relax, 'calc'))
191
192
193 self.exec_tests(self.jw_test_array)
194
195
196
197
198
199
200 self.heading("The consistency tests tests")
201
202
203 self.consistent_test_array = []
204
205
206 self.consistent_test_array.append(Consistent(self.relax, 'set'))
207 self.consistent_test_array.append(Consistent(self.relax, 'calc'))
208
209
210 self.exec_tests(self.consistent_test_array)
211
212
213
214
215
216
217 self.heading("The model selection tests")
218
219
220 self.modsel_test_array = []
221
222
223 self.modsel_test_array.append(Modsel(self.relax, 'diff tensor'))
224
225
226 self.exec_tests(self.modsel_test_array)
227
228
229
230
231
232
233 self.heading("The generic tests")
234
235
236 self.generic_test_array = []
237
238
239 self.generic_test_array.append(Generic(self.relax, 'value_diff'))
240
241
242 self.exec_tests(self.generic_test_array)
243
244
245
246
247
248 self.summary()
249
250
251
253 """Function for printing the headings."""
254
255
256 sys.stdout.write("\n\n\n\n")
257
258
259 for i in xrange(len(text) + 4):
260 sys.stdout.write("#")
261 sys.stdout.write("\n")
262
263
264 sys.stdout.write("# " + text + " #\n")
265
266
267 for i in xrange(len(text) + 4):
268 sys.stdout.write("#")
269 sys.stdout.write("\n\n\n")
270
271
273 """Function for running the tests."""
274
275
276 for i in xrange(len(test_array)):
277
278 string = "# Executing the test of " + test_array[i].name + '.'
279 sys.stdout.write(string + '\n')
280 for j in range(len(string)):
281 sys.stdout.write('#')
282 sys.stdout.write("\n\n")
283
284
285 self.relax.interpreter._Init_data.init()
286
287
288 self.run = 'test'
289
290
291 test_array[i].passed = 0
292
293
294 try:
295 test_array[i].passed = test_array[i].test(self.run)
296
297
298 except:
299 traceback.print_exc()
300
301
302 sys.stdout.write("\n\n\n\n\n\n\n")
303
304
305 if not test_array[i].passed and Debug:
306 sys.exit()
307
308
310 """Function for printing out a summary of all tests."""
311
312
313 sys.stdout.write("\n\n\n")
314 self.heading("Results of the test suite")
315
316
317 global_pass = 1
318
319
320
321
322
323
324 sys.stdout.write("\nThe run tests:\n")
325
326
327 for test in self.run_test_array:
328
329 global_pass = global_pass and test.passed
330
331
332 self.summary_line(test)
333
334
335
336
337
338
339 sys.stdout.write("\nThe sequence tests:\n")
340
341
342 for test in self.seq_test_array:
343
344 global_pass = global_pass and test.passed
345
346
347 self.summary_line(test)
348
349
350
351
352
353
354 sys.stdout.write("\nThe diffusion tensor tests:\n")
355
356
357 for test in self.diff_tensor_test_array:
358
359 global_pass = global_pass and test.passed
360
361
362 self.summary_line(test)
363
364
365
366
367
368
369 sys.stdout.write("\nAngle calculation tests:\n")
370
371
372 for test in self.angles_test_array:
373
374 global_pass = global_pass and test.passed
375
376
377 self.summary_line(test)
378
379
380
381
382
383
384 sys.stdout.write("\nThe relaxation curve-fitting tests:\n")
385
386
387 for test in self.relax_fit_test_array:
388
389 global_pass = global_pass and test.passed
390
391
392 self.summary_line(test)
393
394
395
396
397
398
399 sys.stdout.write("\nThe model-free tests:\n")
400
401
402 for test in self.mf_test_array:
403
404 global_pass = global_pass and test.passed
405
406
407 self.summary_line(test)
408
409
410
411
412
413
414 sys.stdout.write("\nThe reduced spectral density tests:\n")
415
416
417 for test in self.jw_test_array:
418
419 global_pass = global_pass and test.passed
420
421
422 self.summary_line(test)
423
424
425
426
427
428
429 sys.stdout.write("\nThe consistency tests tests:\n")
430
431
432 for test in self.consistent_test_array:
433
434 global_pass = global_pass and test.passed
435
436
437 self.summary_line(test)
438
439
440
441
442
443
444 sys.stdout.write("\nThe model selection tests:\n")
445
446
447 for test in self.modsel_test_array:
448
449 global_pass = global_pass and test.passed
450
451
452 self.summary_line(test)
453
454
455
456
457
458
459 sys.stdout.write("\nThe generic tests:\n")
460
461
462 for test in self.generic_test_array:
463
464 global_pass = global_pass and test.passed
465
466
467 self.summary_line(test)
468
469
470
471
472
473
474 sys.stdout.write("\n\n\nSynopsis ")
475
476
477 for j in xrange(88 - len("Synopsis")):
478 sys.stdout.write(".")
479
480
481 if global_pass:
482 sys.stdout.write(" %-10s\n" % "[ OK ]")
483
484
485 else:
486 sys.stdout.write(" %-10s\n" % "[ Failed ]")
487 sys.stdout.write("\n\n")
488
489
491 """Function for printing the summary lines."""
492
493
494 sys.stdout.write(" " + test.name + " ")
495
496
497 for j in xrange(84 - len(test.name)):
498 sys.stdout.write(".")
499
500
501 if test.passed:
502 sys.stdout.write(" %-10s\n" % "[ OK ]")
503
504
505 else:
506 sys.stdout.write(" %-10s\n" % "[ Failed ]")
507 self.global_pass = 0
508