-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathtest_pipe_proc.py
More file actions
377 lines (252 loc) · 8.19 KB
/
test_pipe_proc.py
File metadata and controls
377 lines (252 loc) · 8.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#! /usr/bin/env python
# pipe_proc module tests, calls scripts in pipe_proc_tests directory.
import os
import nmrglue as ng
# Framework functions
def _perform_test(glue_script, pipe_script, glue_files, pipe_files,
ignore_pipe_display=False):
"""
"""
cwd_backup = os.getcwd() # save the current working directory
# decent into the pipe_proc_tests directory
script_dir, script_fname = os.path.split(os.path.realpath(__file__))
os.chdir(os.path.join(script_dir, 'pipe_proc_tests'))
# execute the scripts and compare the files
exec(open(glue_script).read())
os.system(pipe_script)
for glue_file, pipe_file in zip(glue_files, pipe_files):
glue_dic, glue_data = ng.pipe.read(glue_file)
pipe_dic, pipe_data = ng.pipe.read(pipe_file)
os.remove(glue_file)
os.remove(pipe_file)
r1, r2 = ng.misc.pair_similar(glue_dic, glue_data, pipe_dic,
pipe_data, True,
ignore_pipe_display=ignore_pipe_display)
print(glue_file, pipe_file, r1, r2)
assert r1 is True
assert r2 is True
# return to the backup-ed directory.
os.chdir(cwd_backup)
return
def _standard_args(func_name, num_files):
""" Generate a set of standard """
glue_files = [func_name+str(i + 1)+'.glue' for i in range(num_files)]
pipe_files = [func_name+str(i + 1)+'.dat' for i in range(num_files)]
pipe_script = './' + func_name + '.com'
glue_script = './' + func_name + '.py'
return glue_script, pipe_script, glue_files, pipe_files
def _standard_test(func_name, num_files, ignore_pipe_display=False):
return _perform_test(*_standard_args(func_name, num_files),
ignore_pipe_display=ignore_pipe_display)
#########################
# Apodization functions #
#########################
def test_apod():
""" APOD function """
return _standard_test('apod', 7)
def test_em():
""" EM function """
return _standard_test('em', 2)
def test_gm():
""" GM function """
return _standard_test('gm', 3)
def test_gmb():
""" GMB function """
return _standard_test('gmb', 2)
def test_jmod():
""" JMOD function """
return _standard_test('jmod', 2)
def test_sp():
""" SP function """
return _standard_test('sp', 2)
def test_sine():
""" SINE function """
return _standard_test('sine', 2)
def test_tm():
""" TM function """
return _standard_test('tm', 2)
def test_tri():
""" TRI function """
return _standard_test('tri', 2)
###################
# Shift functions #
###################
def test_rs():
""" RS function """
return _standard_test('rs', 5)
def test_ls():
""" LS function """
return _standard_test('ls', 5)
def test_cs():
""" CS function """
return _standard_test('cs', 8)
# XXX fsh test 1-4 fail
def test_fsh():
""" FSH function """
return _standard_test('fsh', 0)
##############
# Transforms #
##############
def test_ft():
""" FT function """
return _standard_test('ft', 8)
def test_rft():
""" RFT function """
# return _standard_test('rft', 14) # XXX tests 9-11 fail
glue_files = ['rft1.glue', 'rft2.glue', 'rft3.glue', 'rft4.glue',
'rft5.glue', 'rft6.glue', 'rft7.glue', 'rft8.glue',
'rft12.glue', 'rft13.glue', 'rft14.glue']
pipe_files = ['rft1.dat', 'rft2.dat', 'rft3.dat', 'rft4.dat',
'rft5.dat', 'rft6.dat', 'rft7.dat', 'rft8.dat',
'rft12.dat', 'rft13.dat', 'rft14.dat']
pipe_script = './rft.com'
glue_script = './rft.py'
return _perform_test(glue_script, pipe_script, glue_files, pipe_files)
def test_ha():
""" HA function """
return _standard_test('ha', 2)
def test_ht():
""" HT function """
# return _standard_test('ht', 8) # XXX test 4 fails
glue_files = ['ht1.glue', 'ht2.glue', 'ht3.glue', 'ht5.glue', 'ht6.glue',
'ht7.glue', 'ht8.glue']
pipe_files = ['ht1.dat', 'ht2.dat', 'ht3.dat', 'ht5.dat', 'ht6.dat',
'ht7.dat', 'ht8.dat']
pipe_script = './ht.com'
glue_script = './ht.py'
return _perform_test(glue_script, pipe_script, glue_files, pipe_files)
##########################
# Standard NMR Functions #
##########################
def test_ps():
""" PS function """
return _standard_test('ps', 6)
def test_tp():
""" TP function """
return _standard_test('tp', 9, ignore_pipe_display=True)
def test_ytp():
""" YTP function """
return _standard_test('ytp', 3)
def test_xy2yx():
""" XY2YX function """
return _standard_test('xy2yx', 3)
def test_zf():
""" ZF function """
return _standard_test('zf', 5)
###################
# Basic Utilities #
###################
def test_add():
""" ADD function """
return _standard_test('add', 4) # Note that test 5 fails intentionally
def test_dx():
""" DX function """
return _standard_test('dx', 1)
def test_ext():
""" EXT function """
return _standard_test('ext', 11, ignore_pipe_display=True)
def test_integ():
""" INTEG function """
return _standard_test('integ', 1)
def test_mc():
""" MC function """
return _standard_test('mc', 2)
def test_mir():
""" MIR function """
return _standard_test('mir', 14)
def test_mult():
""" MULT function """
return _standard_test('mult', 3) # Note that test 4 fails intentionally
def test_rev():
""" REV function """
return _standard_test('rev', 3)
def test_set():
""" SET function """
return _standard_test('set', 4)
def test_shuf():
""" SHUF function """
return _standard_test('shuf', 7)
def test_sign():
""" SIGN function """
return _standard_test('sign', 8)
########
# Misc #
########
def test_coadd():
""" COADD function """
return _standard_test('coadd', 2)
def test_coad():
""" COAD function """
return _standard_test('coad', 2)
def test_dev():
""" DEV function """
return _standard_test('dev', 0)
def test_null():
""" NULL function """
return _standard_test('null', 2)
def test_qart():
""" QART function """
return _standard_test('qart', 2)
def test_qmix():
""" QMIX function """
return _standard_test('qmix', 2)
def test_smo():
""" SMO function """
return _standard_test('smo', 3)
def test_zd():
""" ZD function """
return _standard_test('zd', 4)
def test_save():
""" SAVE function """
return _standard_test('save', 2)
######################
# Baseline functions #
######################
def test_base():
""" BASE function """
return _standard_test('base', 7)
def test_cbf():
""" CBF function """
return _standard_test('cbf', 4)
#########
# Units #
#########
def test_units():
""" Units """
return _standard_test('units', 17)
#####################
# Inetgration Tests #
#####################
def test_2D_complex_processing():
""" 2D complex mode processing pipeline """
return _standard_test('2d_complex_processing', 1)
####################################################
# Test which are known to fail for various reasons.#
####################################################
# Tests which fail because of differences between NMRPipe and nmrglue
"""
def test_known_fail():
pipe_files = ['add5.dat',
'mult4.dat',
'shuf8.dat', 'shuf9.dat', 'shuf10.dat']
glue_files = ['add5.glue',
'mult4.glue',
'shuf8.glue', 'shuf9.glue', 'shuf10.glue']
pipe_script = 'known_fail.com'
glue_script = 'known_fail.py'
# also 'shuf11', 'shuf12' and dev1' test all fail intentionally.
return _perform_test(glue_script, pipe_script, glue_files, pipe_files)
"""
# Test which fail and should be fixed
"""
def test_to_fix():
pipe_files = ["fsh1.dat", "fsh2.dat", "fsh3.dat", "fsh4.dat"
"rft9.dat", "rft10.dat", "rft11.dat",
"ht4.dat"]
glue_files = ["fsh1.glue", "fsh2.glue", "fsh3.glue", "fsh4.glue"
"rft9.glue", "rft10.glue", "rft11.glue",
"ht4.glue"]
pipe_script = 'to_fix.com'
glue_script = 'to_fix.py'
return _perform_test(glue_script, pipe_script, glue_files, pipe_files)
"""