22import nmrglue .fileio .simpson as simpson
33import numpy as np
44from numpy .testing import assert_allclose , assert_raises
5+ import os .path
56
67from setup import DATA_DIR
78
8- DD_1D = DATA_DIR + 'simpson_1d/'
9- DD_2D = DATA_DIR + 'simpson_2d/'
9+ DD_1D = os . path . join ( DATA_DIR , 'simpson_1d' )
10+ DD_2D = os . path . join ( DATA_DIR , 'simpson_2d' )
1011
1112def test_1d_time ():
1213 """ reading 1D time domain files """
1314 # read the text, binary, xreim, and rawbin data
14- text_dic , text_data = simpson .read (DD_1D + '1d_text.fid' )
15- bin_dic , bin_data = simpson .read (DD_1D + '1d_bin.fid' )
16- xreim_units , xreim_data = simpson .read (DD_1D + '1d_ftext.fid' )
17- rd , rawbin_data = simpson .read (DD_1D + '1d_rawbin.fid' , spe = False , ndim = 1 )
15+ text_dic , text_data = simpson .read (os . path . join ( DD_1D , '1d_text.fid' ) )
16+ bin_dic , bin_data = simpson .read (os . path . join ( DD_1D , '1d_bin.fid' ) )
17+ xreim_units , xreim_data = simpson .read (os . path . join ( DD_1D , '1d_ftext.fid' ) )
18+ rd , rawbin_data = simpson .read (os . path . join ( DD_1D , '1d_rawbin.fid' ) , spe = False , ndim = 1 )
1819
1920 # check data in text file
2021 assert text_data .shape == (4096 , )
@@ -33,10 +34,10 @@ def test_1d_time():
3334def test_1d_freq ():
3435 """ reading 1D freq domain files """
3536 # read the text, binary, xreim, and rawbin data
36- text_dic , text_data = simpson .read (DD_1D + '1d_text.spe' )
37- bin_dic , bin_data = simpson .read (DD_1D + '1d_bin.spe' )
38- xreim_units , xreim_data = simpson .read (DD_1D + '1d_ftext.spe' )
39- rd , rawbin_data = simpson .read (DD_1D + '1d_rawbin.spe' , spe = True , ndim = 1 )
37+ text_dic , text_data = simpson .read (os . path . join ( DD_1D , '1d_text.spe' ) )
38+ bin_dic , bin_data = simpson .read (os . path . join ( DD_1D , '1d_bin.spe' ) )
39+ xreim_units , xreim_data = simpson .read (os . path . join ( DD_1D , '1d_ftext.spe' ) )
40+ rd , rawbin_data = simpson .read (os . path . join ( DD_1D , '1d_rawbin.spe' ) , spe = True , ndim = 1 )
4041
4142 # check data in text file
4243 assert text_data .shape == (4096 , )
@@ -55,10 +56,10 @@ def test_1d_freq():
5556def test_2d_time ():
5657 """ reading 2D time domain files """
5758 # read the text, binary, xreim, and rawbin data
58- text_dic , text_data = simpson .read (DD_2D + '2d_text.fid' )
59- bin_dic , bin_data = simpson .read (DD_2D + '2d.fid' )
60- xyreim_units , xyreim_data = simpson .read (DD_2D + '2d_ftext.fid' )
61- rd , rawbin_data = simpson .read (DD_2D + '2d_raw.fid' , NP = 128 , NI = 48 , ndim = 2 ,
59+ text_dic , text_data = simpson .read (os . path . join ( DD_2D , '2d_text.fid' ) )
60+ bin_dic , bin_data = simpson .read (os . path . join ( DD_2D , '2d.fid' ) )
61+ xyreim_units , xyreim_data = simpson .read (os . path . join ( DD_2D , '2d_ftext.fid' ) )
62+ rd , rawbin_data = simpson .read (os . path . join ( DD_2D , '2d_raw.fid' ) , NP = 128 , NI = 48 , ndim = 2 ,
6263 spe = False )
6364
6465 # check data in text file
@@ -79,10 +80,10 @@ def test_2d_time():
7980def test_2d_freq ():
8081 """ reading 2D freq domain files """
8182 # read the text, binary, xreim, and rawbin data
82- text_dic , text_data = simpson .read (DD_2D + '2d_text.spe' )
83- bin_dic , bin_data = simpson .read (DD_2D + '2d.spe' )
84- xyreim_units , xyreim_data = simpson .read (DD_2D + '2d_ftext.spe' )
85- rd , rawbin_data = simpson .read (DD_2D + '2d_raw.spe' , ndim = 2 , NP = 256 ,
83+ text_dic , text_data = simpson .read (os . path . join ( DD_2D , '2d_text.spe' ) )
84+ bin_dic , bin_data = simpson .read (os . path . join ( DD_2D , '2d.spe' ) )
85+ xyreim_units , xyreim_data = simpson .read (os . path . join ( DD_2D , '2d_ftext.spe' ) )
86+ rd , rawbin_data = simpson .read (os . path . join ( DD_2D , '2d_raw.spe' ) , ndim = 2 , NP = 256 ,
8687 NI = 512 , spe = True )
8788
8889 # check data in text file
@@ -106,14 +107,14 @@ def test_exceptions_read():
106107 """ raising exceptions due to missing read parameters """
107108
108109 # missing spe parameter
109- assert_raises (ValueError , simpson .read , DD_1D + '1d_rawbin.fid' )
110+ assert_raises (ValueError , simpson .read , os . path . join ( DD_1D , '1d_rawbin.fid' ) )
110111
111112 # missing ndim parameter
112- assert_raises (ValueError , simpson .read , DD_1D + '1d_rawbin.fid' , spe = False )
113+ assert_raises (ValueError , simpson .read , os . path . join ( DD_1D , '1d_rawbin.fid' ) , spe = False )
113114
114115 # missing NP/NI parameter
115- assert_raises (ValueError , simpson .read , DD_2D + '2d_raw.fid' , spe = False ,
116+ assert_raises (ValueError , simpson .read , os . path . join ( DD_2D , '2d_raw.fid' ) , spe = False ,
116117 ndim = 2 )
117118
118119 # bad ftype
119- assert_raises (ValueError , simpson .read , DD_1D + '1d_rawbin.fid' , ftype = 'a' )
120+ assert_raises (ValueError , simpson .read , os . path . join ( DD_1D , '1d_rawbin.fid' ) , ftype = 'a' )
0 commit comments