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

Skip to content

Commit 75cdf01

Browse files
committed
TST: replaced additional paths
1 parent 5eecd2a commit 75cdf01

6 files changed

Lines changed: 342 additions & 253 deletions

File tree

tests/test_agilent.py

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def lowmem_fid_write_readback(dic, data, shape, torder):
5555

5656
@attr(speed='fast')
5757
def test_1d():
58-
""" reading/writing of 1D Varian file """
59-
dic, data = ng.varian.read(DATA_DIR + "agilent_1d")
58+
""" reading/writing of 1D Varian file """
59+
dic, data = ng.varian.read(os.path.join(DATA_DIR, "agilent_1d"))
6060
assert data.shape == (1500, )
6161
assert round(data[0].real, 2) == 91899.24
6262
assert round(data[0].imag, 2) == -1964.70
@@ -66,31 +66,31 @@ def test_1d():
6666

6767
@attr(speed='fast')
6868
def test_2d():
69-
""" reading/writing of 2D Varian file """
70-
dic, data = ng.varian.read(DATA_DIR + "agilent_2d")
71-
assert data.shape == (332, 1500)
72-
assert round(data[0, 1].real, 2) == 360.07
69+
""" reading/writing of 2D Varian file """
70+
dic, data = ng.varian.read(os.path.join(DATA_DIR, "agilent_2d"))
71+
assert data.shape == (332, 1500)
72+
assert round(data[0, 1].real, 2) == 360.07
7373
assert round(data[0, 1].imag, 2) == -223.20
7474
assert round(data[10, 18].real, 2) == 17.93
7575
assert round(data[10, 18].imag, 2) == -67.20
7676
write_readback(dic, data)
7777

7878
@attr(speed='fast')
7979
def test_2d_lowmem():
80-
""" low memory reading/writing of 2D Varian file """
81-
dic, data = ng.varian.read_lowmem(DATA_DIR + "agilent_2d")
82-
assert data.shape == (332, 1500)
83-
assert round(data[0, 1].real, 2) == 360.07
80+
""" low memory reading/writing of 2D Varian file """
81+
dic, data = ng.varian.read_lowmem(os.path.join(DATA_DIR, "agilent_2d"))
82+
assert data.shape == (332, 1500)
83+
assert round(data[0, 1].real, 2) == 360.07
8484
assert round(data[0, 1].imag, 2) == -223.20
8585
assert round(data[10, 18].real, 2) == 17.93
8686
assert round(data[10, 18].imag, 2) == -67.20
8787
lowmem_write_readback(dic, data)
8888

8989
@attr(speed='fast')
9090
def test_2d_tppi():
91-
""" reading/writing of 2D Varian file with TPPI encoding """
92-
dic, data = ng.varian.read(DATA_DIR + "agilent_2d_tppi")
93-
assert data.shape == (600, 1400)
91+
""" reading/writing of 2D Varian file with TPPI encoding """
92+
dic, data = ng.varian.read(os.path.join(DATA_DIR, "agilent_2d_tppi"))
93+
assert data.shape == (600, 1400)
9494
assert round(data[0, 1].real, 2) == -4589.29
9595
assert round(data[0, 1].imag, 2) == -1691.82
9696
assert round(data[10, 18].real, 2) == -166.62
@@ -99,9 +99,10 @@ def test_2d_tppi():
9999

100100
@attr(speed='fast')
101101
def test_2d_tppi_lowmem():
102-
""" low memory reading/writing of 2D Varian file with TPPI encoding """
103-
dic, data = ng.varian.read_lowmem(DATA_DIR + "agilent_2d_tppi")
104-
assert data.shape == (600, 1400)
102+
""" low memory reading/writing of 2D Varian file with TPPI encoding """
103+
dic, data = ng.varian.read_lowmem(os.path.join(DATA_DIR,
104+
"agilent_2d_tppi"))
105+
assert data.shape == (600, 1400)
105106
assert round(data[0, 1].real, 2) == -4589.29
106107
assert round(data[0, 1].imag, 2) == -1691.82
107108
assert round(data[10, 18].real, 2) == -166.62
@@ -110,8 +111,8 @@ def test_2d_tppi_lowmem():
110111

111112
@attr(speed='slow')
112113
def test_3d():
113-
""" reading/writing of 3D Varian file """
114-
dic, data = ng.varian.read(DATA_DIR + "agilent_3d")
114+
""" reading/writing of 3D Varian file """
115+
dic, data = ng.varian.read(os.path.join(DATA_DIR, "agilent_3d"))
115116
assert data.shape == (128, 88, 1250)
116117
assert round(data[0, 1, 2].real, 2) == 7.98
117118
assert round(data[0, 1, 2].imag, 2) == 33.82
@@ -121,8 +122,8 @@ def test_3d():
121122

122123
@attr(speed='slow')
123124
def test_3d_lowmem():
124-
""" low memory reading/writing of 3D Varian file """
125-
dic, data = ng.varian.read_lowmem(DATA_DIR + "agilent_3d")
125+
""" low memory reading/writing of 3D Varian file """
126+
dic, data = ng.varian.read_lowmem(os.path.join(DATA_DIR, "agilent_3d"))
126127
assert data.shape == (128, 88, 1250)
127128
assert round(data[0, 1, 2].real, 2) == 7.98
128129
assert round(data[0, 1, 2].imag, 2) == 33.82
@@ -132,27 +133,28 @@ def test_3d_lowmem():
132133

133134
@attr(speed='slow')
134135
def test_4d():
135-
""" reading/writing of 4D Varian fid file """
136+
""" reading/writing of 4D Varian fid file """
136137
# since this is a fake 4D with no procpar we need to explicitly
137138
# provide the shape and trace ordering parameters
138-
dic, data = ng.varian.read_fid(DATA_DIR + "agilent_4d/fid",
139-
shape=(8, 12, 16, 1400), torder='r')
139+
dic, data = ng.varian.read_fid(os.path.join(DATA_DIR, "agilent_4d/fid"),
140+
shape=(8, 12, 16, 1400), torder='r')
140141
assert data.shape == (8, 12, 16, 1400)
141-
assert round(data[0, 1, 2, 3].real, 2) == 395.11
142+
assert round(data[0, 1, 2, 3].real, 2) == 395.11
142143
assert round(data[0, 1, 2, 3].imag, 2) == 52.72
143144
assert round(data[3, 10, 11, 18].real, 2) == 51.81
144145
assert round(data[3, 10, 11, 18].imag, 2) == 16.01
145146
write_fid_readback(dic, data, (8, 12, 16, 1400),'r')
146147

147148
@attr(speed='slow')
148149
def test_4d_lowmem():
149-
""" low memory reading/writing of 4D Varian fid file """
150+
""" low memory reading/writing of 4D Varian fid file """
150151
# since this is a fake 4D with no procpar we need to explicitly
151152
# provide the shape and trace ordering parameters
152-
dic, data = ng.varian.read_fid_lowmem(DATA_DIR + "agilent_4d/fid",
153-
shape=(8, 12, 16, 1400),torder='r')
153+
dic, data = ng.varian.read_fid_lowmem(
154+
os.path.join(DATA_DIR, "agilent_4d/fid"),
155+
shape=(8, 12, 16, 1400),torder='r')
154156
assert data.shape == (8, 12, 16, 1400)
155-
assert round(data[0, 1, 2, 3].real, 2) == 395.11
157+
assert round(data[0, 1, 2, 3].real, 2) == 395.11
156158
assert round(data[0, 1, 2, 3].imag, 2) == 52.72
157159
assert round(data[3, 10, 11, 18].real, 2) == 51.81
158160
assert round(data[3, 10, 11, 18].imag, 2) == 16.01

tests/test_bruker.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ def lowmem_write_readback(dic, data):
4545
# tests
4646
def test_jcamp1():
4747
""" reading/writing of JCAMP file 1"""
48-
dic = ng.bruker.read_jcamp(DATA_DIR + "bruker_1d/acqus")
48+
dic = ng.bruker.read_jcamp(os.path.join(DATA_DIR, "bruker_1d", "acqus"))
4949
assert dic['LFILTER'] == 200
5050
assert len(dic['PRECHAN']) == 16
5151
tf = tempfile.mktemp(dir='.')
5252
ng.bruker.write_jcamp(dic, tf)
5353
ndic = ng.bruker.read_jcamp(tf)
5454
assert dic_similar(dic, ndic)
5555
os.remove(tf)
56-
56+
5757
def test_jcamp2():
5858
""" reading/writing of JCAMP file 2"""
59-
dic = ng.bruker.read_jcamp(DATA_DIR + "bruker_2d/acqu2s")
59+
dic = ng.bruker.read_jcamp(os.path.join(DATA_DIR, "bruker_2d", "acqu2s"))
6060
tf = tempfile.mktemp(dir='.')
6161
ng.bruker.write_jcamp(dic, tf)
6262
ndic = ng.bruker.read_jcamp(tf)
@@ -65,7 +65,8 @@ def test_jcamp2():
6565

6666
def test_pprog():
6767
""" reading/writing of pulse program"""
68-
dic = ng.bruker.read_pprog(DATA_DIR + "bruker_3d/pulseprogram")
68+
dic = ng.bruker.read_pprog(os.path.join(DATA_DIR, "bruker_3d",
69+
"pulseprogram"))
6970
assert dic['var']['LOOPC'] == '58'
7071
assert len(dic['incr']) == 4
7172
tf = tempfile.mktemp(dir='.')
@@ -76,7 +77,7 @@ def test_pprog():
7677

7778
def test_1d():
7879
""" reading/writing of 1D bruker data"""
79-
dic, data = ng.bruker.read(DATA_DIR + "bruker_1d")
80+
dic, data = ng.bruker.read(os.path.join(DATA_DIR, "bruker_1d"))
8081
assert dic['FILE_SIZE'] == 16384
8182
assert data.shape == (2048, )
8283
assert round(data[20].real, 2) == -282.0
@@ -88,7 +89,7 @@ def test_1d():
8889

8990
def test_2d():
9091
""" reading/writing of 2D bruker data"""
91-
dic, data = ng.bruker.read(DATA_DIR + "bruker_2d")
92+
dic, data = ng.bruker.read(os.path.join(DATA_DIR, "bruker_2d"))
9293
assert dic['FILE_SIZE'] == 3686400
9394
assert data.shape == (600, 768)
9495
assert round(data[0, 40].real, 2) == 28.0
@@ -99,7 +100,7 @@ def test_2d():
99100

100101
def test_2d_lowmem():
101102
""" lowmemory reading/writing of 2D bruker data"""
102-
dic, data = ng.bruker.read_lowmem(DATA_DIR + "bruker_2d")
103+
dic, data = ng.bruker.read_lowmem(os.path.join(DATA_DIR, "bruker_2d"))
103104
assert dic['FILE_SIZE'] == 3686400
104105
assert data.shape == (600, 768)
105106
assert round(data[0, 40].real, 2) == 28.0
@@ -110,22 +111,22 @@ def test_2d_lowmem():
110111

111112
def test_3d():
112113
""" reading/writing of 3D bruker data"""
113-
dic, data = ng.bruker.read(DATA_DIR + "bruker_3d")
114+
dic, data = ng.bruker.read(os.path.join(DATA_DIR, "bruker_3d"))
114115
assert dic['FILE_SIZE'] == 91226112
115116
assert data.shape == (116, 128, 768)
116117
assert round(data[0, 0, 40].real, 2) == 18.0
117118
assert round(data[0, 0, 40].imag, 2) == -66.0
118-
assert round(data[5, 13, 91].real, 2) == 1138.0
119+
assert round(data[5, 13, 91].real, 2) == 1138.0
119120
assert round(data[5, 13, 91].imag, 2) == 3482.0
120121
write_readback(dic, data)
121122

122123
def test_3d_lowmem():
123124
""" low memory reading/writing of 3D bruker data"""
124-
dic, data = ng.bruker.read_lowmem(DATA_DIR + "bruker_3d")
125+
dic, data = ng.bruker.read_lowmem(os.path.join(DATA_DIR, "bruker_3d"))
125126
assert dic['FILE_SIZE'] == 91226112
126127
assert data.shape == (116, 128, 768)
127128
assert round(data[0, 0, 40].real, 2) == 18.0
128129
assert round(data[0, 0, 40].imag, 2) == -66.0
129-
assert round(data[5, 13, 91].real, 2) == 1138.0
130+
assert round(data[5, 13, 91].real, 2) == 1138.0
130131
assert round(data[5, 13, 91].imag, 2) == 3482.0
131132
lowmem_write_readback(dic, data)

0 commit comments

Comments
 (0)