Skip to content

Commit 385522b

Browse files
committed
Updated tests
1 parent 1573a0c commit 385522b

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

tests/test_eprpy.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_get_dim_arrays():
7272
test_ntup,test_dim = get_dim_arrays(test_dsc_dict,Path(test_filepath_dta))
7373

7474
assert test_ntup == (1, 1, 2048)
75-
np.testing.assert_array_equal(exp_dim,test_dim)
75+
np.testing.assert_array_almost_equal(exp_dim,test_dim)
7676

7777
def test_get_DTA_datatype():
7878
test_filepath_dsc = data_dir+'/tempo.DSC'
@@ -90,8 +90,8 @@ def test_read_DTA_file():
9090

9191
test_datadta,test_dimlist = read_DTA_file(Path(test_filepath_dta),test_dsc_dict)
9292

93-
np.testing.assert_array_equal(exp_datadata,test_datadta)
94-
np.testing.assert_array_equal(test_dimlist[0],exp_dimlist0)
93+
np.testing.assert_array_almost_equal(exp_datadata,test_datadta)
94+
np.testing.assert_array_almost_equal(test_dimlist[0],exp_dimlist0)
9595
assert isinstance(test_dimlist,list)
9696

9797
def test_read_GF_file():
@@ -108,7 +108,7 @@ def test_read_GF_file():
108108
test_dsc_dict = read_DSC_file(Path(test_filepath_dsc))
109109
exp_gf_data = np.load(data_dir+'/test_read_GF_file_data.npy')
110110

111-
np.testing.assert_array_equal(exp_gf_data,read_GF_file('Y',test_dsc_dict,Path(test_filepath_dta)))
111+
np.testing.assert_array_almost_equal(exp_gf_data,read_GF_file('Y',test_dsc_dict,Path(test_filepath_dta)))
112112

113113
with pytest.raises(FileNotFoundError):
114114
_ = read_GF_file('X',test_dsc_dict,Path(test_filepath_dta))
@@ -126,8 +126,8 @@ def test_load_1d_epr(self,test_load_1d):
126126
exp_x = np.load(data_dir+'/test_load_1d_epr_x.npy')
127127
exp_data = np.load(data_dir+'/test_load_1d_epr.npy')
128128

129-
np.testing.assert_array_equal(exp_x,test_load_1d.x)
130-
np.testing.assert_array_equal(exp_data,test_load_1d.data)
129+
np.testing.assert_array_almost_equal(exp_x,test_load_1d.x)
130+
np.testing.assert_array_almost_equal(exp_data,test_load_1d.data)
131131

132132
test_filepath_dsc = data_dir+'/tempo.DSC'
133133
test_dsc_dict = read_DSC_file(Path(test_filepath_dsc))
@@ -139,32 +139,32 @@ def test_load_1d_epr(self,test_load_1d):
139139
def test_scale_between(self,test_load_1d):
140140

141141
exp_data = np.load(data_dir+'/test_scale_between1d_default.npy')
142-
np.testing.assert_array_equal(test_load_1d.scale_between().data,exp_data)
142+
np.testing.assert_array_almost_equal(test_load_1d.scale_between().data,exp_data)
143143

144144
exp_data = np.load(data_dir+'/test_scale_between1d-1_1.npy')
145-
np.testing.assert_array_equal(test_load_1d.scale_between(-1,1).data,exp_data)
145+
np.testing.assert_array_almost_equal(test_load_1d.scale_between(-1,1).data,exp_data)
146146

147147
def test_integral(self,test_load_1d):
148148

149149
exp_data = np.load(data_dir+'/test_integral.npy')
150-
np.testing.assert_array_equal(test_load_1d.integral().data,exp_data)
150+
np.testing.assert_array_almost_equal(test_load_1d.integral().data,exp_data)
151151

152152
def test_baseline_correction(self,test_load_1d):
153153

154154
exp_data = np.load(data_dir+'/test_default_bc.npy')
155-
np.testing.assert_array_equal(test_load_1d.baseline_correct().data,exp_data)
155+
np.testing.assert_array_almost_equal(test_load_1d.baseline_correct().data,exp_data)
156156

157157
exp_data = np.load(data_dir+'/test_poly2_bc.npy')
158-
np.testing.assert_array_equal(test_load_1d.baseline_correct(method='polynomial',order=2).data,exp_data)
158+
np.testing.assert_array_almost_equal(test_load_1d.baseline_correct(method='polynomial',order=2).data,exp_data)
159159

160160
exp_data = np.load(data_dir+'/test_poly2_bc_baseline.npy')
161-
np.testing.assert_array_equal(test_load_1d.baseline_correct(method='polynomial',order=2).baseline,exp_data)
161+
np.testing.assert_array_almost_equal(test_load_1d.baseline_correct(method='polynomial',order=2).baseline,exp_data)
162162

163163
exp_data = np.load(data_dir+'/test_spline_bc.npy')
164-
np.testing.assert_array_equal(test_load_1d.baseline_correct(method='spline').data,exp_data)
164+
np.testing.assert_array_almost_equal(test_load_1d.baseline_correct(method='spline').data,exp_data)
165165

166166
exp_data = np.load(data_dir+'/test_spline_bc_baseline.npy')
167-
np.testing.assert_array_equal(test_load_1d.baseline_correct(method='spline').baseline,exp_data)
167+
np.testing.assert_array_almost_equal(test_load_1d.baseline_correct(method='spline').baseline,exp_data)
168168

169169
def test_plot(self,test_load_1d):
170170
fig,ax=test_load_1d.plot()
@@ -181,9 +181,9 @@ def test_load_2d_epr(self,test_load_2d):
181181
exp_data = np.load(data_dir+'/test_load_2d_epr.npy')
182182
exp_y = np.load(data_dir+'/test_load_2d_epr_y.npy')
183183

184-
np.testing.assert_array_equal(exp_x,test_load_2d.x)
185-
np.testing.assert_array_equal(exp_y,test_load_2d.y)
186-
np.testing.assert_array_equal(exp_data,test_load_2d.data)
184+
np.testing.assert_array_almost_equal(exp_x,test_load_2d.x)
185+
np.testing.assert_array_almost_equal(exp_y,test_load_2d.y)
186+
np.testing.assert_array_almost_equal(exp_data,test_load_2d.data)
187187

188188
test_filepath_dsc = data_dir+'/tempo_time.DSC'
189189
test_dsc_dict = read_DSC_file(Path(test_filepath_dsc))
@@ -195,12 +195,12 @@ def test_load_2d_epr(self,test_load_2d):
195195
def test_scale_between(self,test_load_2d):
196196

197197
exp_data = np.load(data_dir+'/test_scale_between2d_default.npy')
198-
np.testing.assert_array_equal(test_load_2d.scale_between().data,exp_data)
198+
np.testing.assert_array_almost_equal(test_load_2d.scale_between().data,exp_data)
199199

200200
def test_baseline_correction(self,test_load_2d):
201201

202202
exp_data = np.load(data_dir+'/test_default2d_bc.npy')
203-
np.testing.assert_array_equal(test_load_2d.baseline_correct().data,exp_data)
203+
np.testing.assert_array_almost_equal(test_load_2d.baseline_correct().data,exp_data)
204204

205205
def test_plot(self,test_load_2d):
206206
fig,ax=test_load_2d.plot()

0 commit comments

Comments
 (0)