Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7e8ec3

Browse files
committed
Merge pull request jjhelmus#16 from tjragan/pipe_fix
BUG: Two NMRPipe related fixes.
2 parents 7cb5f19 + 5a47753 commit e7e8ec3

7 files changed

Lines changed: 151 additions & 10 deletions

File tree

nmrglue/process/pipe_proc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,7 @@ def ext(dic, data, x1="default", xn="default", y1="default", yn="default",
20332033
data = data[y_min:y_max, x_min:x_max]
20342034
if y_min != 1 and y_max != data.shape[0]: # only update when sliced
20352035
dic["FDSLICECOUNT"] = y_max - y_min
2036-
dic["FDSPECNUM"] = y_max - y_min
2036+
dic["FDSPECNUM"] = y_max - y_min
20372037
dic["FDSIZE"] = x_max - x_min
20382038

20392039
else: # 1D Array

nmrglue/util/misc.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def pair_similar(dic1, data1, dic2, data2, verb=False, atol=ATOL, rtol=RTOL,
14-
dtol=DTOL):
14+
dtol=DTOL, ignore_pipe_display=False):
1515
"""
1616
Check a dic, data pair against a second dic, data pair for differences.
1717
@@ -41,7 +41,8 @@ def pair_similar(dic1, data1, dic2, data2, verb=False, atol=ATOL, rtol=RTOL,
4141
4242
"""
4343
r1 = isdatasimilar(data1, data2, verb, atol, rtol)
44-
r2 = isdicsimilar(dict(dic1), dict(dic2), verb, dtol)
44+
r2 = isdicsimilar(dict(dic1), dict(dic2), verb, dtol,
45+
ignore_pipe_display=ignore_pipe_display)
4546
return r1, r2
4647

4748

@@ -124,7 +125,7 @@ def isitemsimilar(v1, v2, verb=False, dtol=DTOL):
124125
return r
125126

126127

127-
def isdicsimilar(dic1, dic2, verb=False, dtol=DTOL):
128+
def isdicsimilar(dic1, dic2, verb=False, dtol=DTOL, ignore_pipe_display=False):
128129
"""
129130
Compare two dictionaries for differences
130131
@@ -161,6 +162,13 @@ def isdicsimilar(dic1, dic2, verb=False, dtol=DTOL):
161162
kset2 = set(dic2.keys())
162163
dset = set.difference(kset1, kset2)
163164
iset = set.intersection(kset1, kset2)
165+
166+
if ignore_pipe_display == True:
167+
iset.discard('FDMIN')
168+
iset.discard('FDMAX')
169+
iset.discard('FDDISPMIN')
170+
iset.discard('FDDISPMAX')
171+
iset.discard('FDSCALEFLAG')
164172

165173
# print out any keys not in both dictionaries
166174
if len(dset) != 0:

tests/pipe_proc_tests/ext.com

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,33 @@ nmrPipe -in ./time_complex.fid \
2727
nmrPipe -in ./time_complex.fid \
2828
| nmrPipe -fn EXT -x1 5 -xn 200 -round 10 -sw \
2929
-ov -out ext7.dat
30+
31+
32+
nmrPipe -in ./time_complex.fid \
33+
| nmrPipe -fn FT -auto \
34+
-ov -out time-freq.c.ft1
35+
36+
nmrPipe -in ./time-freq.c.ft1 \
37+
| nmrPipe -fn EXT -left -sw\
38+
-ov -out ext8.dat
39+
40+
nmrPipe -in ./time-freq.c.ft1 \
41+
| nmrPipe -fn EXT -right -sw\
42+
-ov -out ext9.dat
43+
44+
rm -f time-freq.c.ft1
45+
46+
47+
nmrPipe -in ./time_complex.fid \
48+
| nmrPipe -fn FT -auto -di \
49+
-ov -out time-freq.r.ft1
50+
51+
nmrPipe -in ./time-freq.r.ft1 \
52+
| nmrPipe -fn EXT -left -sw\
53+
-ov -out ext10.dat
54+
55+
nmrPipe -in ./time-freq.r.ft1 \
56+
| nmrPipe -fn EXT -right -sw\
57+
-ov -out ext11.dat
58+
59+
rm -f time-freq.r.ft1

tests/pipe_proc_tests/ext.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#! /usr/bin/env python
22
""" Create files for ext unit test """
33

4+
from subprocess import check_output
5+
46
import nmrglue.fileio.pipe as pipe
57
import nmrglue.process.pipe_proc as p
68

@@ -31,3 +33,37 @@
3133
d, a = pipe.read("time_complex.fid")
3234
d, a = p.ext(d, a, x1=5, xn=200, round=10)
3335
pipe.write("ext7.glue", d, a, overwrite=True)
36+
37+
38+
pipe_command = """\
39+
nmrPipe -in ./time_complex.fid \
40+
| nmrPipe -fn FT -auto \
41+
-ov -out time-freq.c.ft1"""
42+
check_output(pipe_command, shell=True)
43+
44+
d, a = pipe.read("time-freq.c.ft1")
45+
d, a = p.ext(d, a, left=True, sw=True)
46+
pipe.write("ext8.glue", d, a, overwrite=True)
47+
48+
d, a = pipe.read("time-freq.c.ft1")
49+
d, a = p.ext(d, a, right=True, sw=True)
50+
pipe.write("ext9.glue", d, a, overwrite=True)
51+
52+
os.remove("time-freq.c.ft1")
53+
54+
55+
pipe_command = """\
56+
nmrPipe -in ./time_complex.fid \
57+
| nmrPipe -fn FT -auto -di \
58+
-ov -out time-freq.r.ft1"""
59+
check_output(pipe_command, shell=True)
60+
61+
d, a = pipe.read("time-freq.r.ft1")
62+
d, a = p.ext(d, a, left=True, sw=True)
63+
pipe.write("ext10.glue", d, a, overwrite=True)
64+
65+
d, a = pipe.read("time-freq.r.ft1")
66+
d, a = p.ext(d, a, right=True, sw=True)
67+
pipe.write("ext11.glue", d, a, overwrite=True)
68+
69+
os.remove("time-freq.r.ft1")

tests/pipe_proc_tests/tp.com

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,32 @@ nmrPipe -in ./time_complex.fid \
1111
nmrPipe -in ./time_complex.fid \
1212
| nmrPipe -fn TP -nohyper \
1313
-ov -out tp3.dat
14+
15+
16+
nmrPipe -in ./time_complex.fid \
17+
| nmrPipe -fn FT -auto \
18+
-ov -out time-freq.c.ft1
19+
20+
nmrPipe -in ./time-freq.c.ft1 \
21+
| nmrPipe -fn TP -hyper\
22+
-ov -out tp4.dat
23+
24+
nmrPipe -in ./time-freq.c.ft1 \
25+
| nmrPipe -fn TP -auto\
26+
-ov -out tp5.dat
27+
28+
rm -f time-freq.c.ft1
29+
30+
nmrPipe -in ./time_complex.fid \
31+
| nmrPipe -fn FT -auto -di \
32+
-ov -out time-freq.r.ft1
33+
34+
nmrPipe -in ./time-freq.r.ft1 \
35+
| nmrPipe -fn TP \
36+
-ov -out tp6.dat
37+
38+
nmrPipe -in ./time-freq.r.ft1 \
39+
| nmrPipe -fn TP -auto \
40+
-ov -out tp7.dat
41+
42+
rm -f time-freq.r.ft1

tests/pipe_proc_tests/tp.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#! /usr/bin/env python
22
""" Create files for tp unit test """
33

4+
from subprocess import check_output
5+
46
import nmrglue.fileio.pipe as pipe
57
import nmrglue.process.pipe_proc as p
68

@@ -15,3 +17,36 @@
1517
d, a = pipe.read("time_complex.fid")
1618
d, a = p.tp(d, a, nohyper=True)
1719
pipe.write("tp3.glue", d, a, overwrite=True)
20+
21+
22+
pipe_command = """\
23+
nmrPipe -in ./time_complex.fid \
24+
| nmrPipe -fn FT -auto \
25+
-ov -out time-freq.c.ft1"""
26+
check_output(pipe_command, shell=True)
27+
28+
d, a = pipe.read("time-freq.c.ft1")
29+
d, a = p.tp(d, a, hyper=True)
30+
pipe.write("tp4.glue", d, a, overwrite=True)
31+
32+
d, a = pipe.read("time-freq.c.ft1")
33+
d, a = p.tp(d, a, auto=True)
34+
pipe.write("tp5.glue", d, a, overwrite=True)
35+
36+
os.remove("time-freq.c.ft1")
37+
38+
pipe_command = """\
39+
nmrPipe -in ./time_complex.fid \
40+
| nmrPipe -fn FT -auto -di \
41+
-ov -out time-freq.r.ft1"""
42+
check_output(pipe_command, shell=True)
43+
44+
d, a = pipe.read("time-freq.r.ft1")
45+
d, a = p.tp(d, a)
46+
pipe.write("tp6.glue", d, a, overwrite=True)
47+
48+
d, a = pipe.read("time-freq.r.ft1")
49+
d, a = p.tp(d, a, auto=True)
50+
pipe.write("tp7.glue", d, a, overwrite=True)
51+
52+
os.remove("time-freq.r.ft1")

tests/test_pipe_proc.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
# Framework functions
88

9-
def _perform_test(glue_script, pipe_script, glue_files, pipe_files):
9+
def _perform_test(glue_script, pipe_script, glue_files, pipe_files,
10+
ignore_pipe_display=False):
1011
"""
1112
"""
1213
cwd_backup = os.getcwd() # save the current working directory
@@ -26,7 +27,8 @@ def _perform_test(glue_script, pipe_script, glue_files, pipe_files):
2627
os.remove(glue_file)
2728
os.remove(pipe_file)
2829
r1, r2 = ng.misc.pair_similar(glue_dic, glue_data, pipe_dic,
29-
pipe_data, True)
30+
pipe_data, True,
31+
ignore_pipe_display=ignore_pipe_display)
3032
print glue_file, pipe_file, r1, r2
3133
assert r1 is True
3234
assert r2 is True
@@ -43,8 +45,9 @@ def _standard_args(func_name, num_files):
4345
glue_script = './' + func_name + '.py'
4446
return glue_script, pipe_script, glue_files, pipe_files
4547

46-
def _standard_test(func_name, num_files):
47-
return _perform_test(*_standard_args(func_name, num_files))
48+
def _standard_test(func_name, num_files, ignore_pipe_display=False):
49+
return _perform_test(*_standard_args(func_name, num_files),
50+
ignore_pipe_display =ignore_pipe_display)
4851

4952

5053
#########################
@@ -153,7 +156,7 @@ def test_ps():
153156

154157
def test_tp():
155158
""" TP function """
156-
return _standard_test('tp', 3)
159+
return _standard_test('tp', 7, ignore_pipe_display=True)
157160

158161
def test_ytp():
159162
""" YTP function """
@@ -181,7 +184,7 @@ def test_dx():
181184

182185
def test_ext():
183186
""" EXT function """
184-
return _standard_test('ext', 7)
187+
return _standard_test('ext', 11, ignore_pipe_display=True)
185188

186189
def test_integ():
187190
""" INTEG function """

0 commit comments

Comments
 (0)