1717from datetime import datetime
1818import numpy as np
1919import numpy .testing as npt
20- from xarray .testing import assert_equal , assert_identical , assert_allclose
21- warnings .simplefilter ('ignore' , UserWarning )
20+ from xarray .testing import assert_identical , assert_allclose
2221atexit .register (pkg_resources .cleanup_resources )
2322
2423# Base definitions
@@ -80,6 +79,7 @@ class io_testcase(unittest.TestCase):
8079 @classmethod
8180 def setUpClass (self ):
8281 sys .stdout = open (os .devnull , 'w' ) # block printing output
82+ warnings .simplefilter ('ignore' , UserWarning )
8383 #pass
8484
8585 @classmethod
@@ -95,7 +95,7 @@ def test_save(self):
9595 assert os .path .exists (rfnm ('test_save.mat' ))
9696
9797
98- def test_read (self ):
98+ def test_io_adv (self ):
9999 td = read ('vector_data01.VEC' , nens = 100 )
100100 tdm = read ('vector_data_imu01.VEC' ,
101101 userdata = False ,
@@ -113,11 +113,11 @@ def test_read(self):
113113 tdm = set_inst2head_rotmat (tdm , np .eye (3 ))
114114 tdm .attrs ['inst2head_vec' ] = np .array ([- 1.0 , 0.5 , 0.2 ])
115115
116- assert_equal (td , dat )
117- assert_equal (tdm , dat_imu )
118- assert_equal (tdb , dat_burst )
119- assert_equal (tdm2 , dat_imu_json )
120- assert_equal (td_debug , tdm2 )
116+ assert_allclose (td , dat , atol = 1e-6 )
117+ assert_allclose (tdm , dat_imu , atol = 1e-6 )
118+ assert_allclose (tdb , dat_burst , atol = 1e-6 )
119+ assert_allclose (tdm2 , dat_imu_json , atol = 1e-6 )
120+ assert_allclose (td_debug , tdm2 , atol = 1e-6 )
121121
122122
123123 def test_io_rdi (self ):
@@ -129,12 +129,12 @@ def test_io_rdi(self):
129129 td_debug = drop_config (wh .read_rdi (exdt ('RDI_withBT.000' ), debug = 11 ,
130130 nens = 500 ))
131131
132- assert_equal (td_rdi , dat_rdi )
133- assert_equal (td_rdi_bt , dat_rdi_bt )
134- assert_equal (td_vm , dat_rdi_vm )
135- assert_equal (td_wr1 , dat_wr1 )
136- assert_equal (td_wr2 , dat_wr2 )
137- assert_equal (td_debug , td_rdi_bt )
132+ assert_allclose (td_rdi , dat_rdi , atol = 1e-6 )
133+ assert_allclose (td_rdi_bt , dat_rdi_bt , atol = 1e-6 )
134+ assert_allclose (td_vm , dat_rdi_vm , atol = 1e-6 )
135+ assert_allclose (td_wr1 , dat_wr1 , atol = 1e-6 )
136+ assert_allclose (td_wr2 , dat_wr2 , atol = 1e-6 )
137+ assert_allclose (td_debug , td_rdi_bt , atol = 1e-6 )
138138
139139
140140 def test_io_nortek (self ):
@@ -144,10 +144,10 @@ def test_io_nortek(self):
144144 td_debug = drop_config (awac .read_nortek (exdt ('AWAC_test01.wpr' ),
145145 debug = True , do_checksum = True , nens = 500 ))
146146
147- assert_equal (td_awac , dat_awac )
148- assert_equal (td_awac_ud , dat_awac_ud )
149- assert_equal (td_hwac , dat_hwac )
150- assert_equal (td_awac_ud , td_debug )
147+ assert_allclose (td_awac , dat_awac , atol = 1e-6 )
148+ assert_allclose (td_awac_ud , dat_awac_ud , atol = 1e-6 )
149+ assert_allclose (td_hwac , dat_hwac , atol = 1e-6 )
150+ assert_allclose (td_awac_ud , td_debug , atol = 1e-6 )
151151
152152
153153 def test_io_nortek2 (self ):
@@ -162,11 +162,11 @@ def test_io_nortek2(self):
162162 os .remove (exdt ('VelEchoBT01.ad2cp.index' ))
163163 os .remove (exdt ('Sig500_Echo.ad2cp.index' ))
164164
165- assert_equal (td_sig , dat_sig )
166- assert_equal (td_sig_i , dat_sig_i )
167- assert_equal (td_sig_i_ud , dat_sig_i_ud )
168- assert_equal (td_sig_ieb , dat_sig_ieb )
169- assert_equal (td_sig_ie , dat_sig_ie )
165+ assert_allclose (td_sig , dat_sig , atol = 1e-6 )
166+ assert_allclose (td_sig_i , dat_sig_i , atol = 1e-6 )
167+ assert_allclose (td_sig_i_ud , dat_sig_i_ud , atol = 1e-6 )
168+ assert_allclose (td_sig_ieb , dat_sig_ieb , atol = 1e-6 )
169+ assert_allclose (td_sig_ie , dat_sig_ie , atol = 1e-6 )
170170
171171
172172 def test_badtime (self ):
@@ -213,7 +213,7 @@ def test_heading(self):
213213 td ['heading' ].values = head
214214
215215 cd = load ('vector_data_imu01_head_pitch_roll.nc' )
216- assert_equal (td , cd )
216+ assert_allclose (td , cd , atol = 1e-7 )
217217
218218
219219 def test_inst2head_rotmat (self ):
@@ -229,19 +229,20 @@ def test_inst2head_rotmat(self):
229229 # (td.Veldata.w == -tr.dat.Veldata.w).all()
230230 # ), "head->inst rotations give unexpeced results."
231231 #Coords don't get altered here
232- npt .assert_allclose (td .Veldata .u .values , dat .Veldata .v .values )
233- npt .assert_allclose (td .Veldata .v .values , dat .Veldata .u .values )
234- npt .assert_allclose (td .Veldata .w .values , - dat .Veldata .w .values )
232+ npt .assert_allclose (td .Veldata .u .values , dat .Veldata .v .values , atol = 1e-6 )
233+ npt .assert_allclose (td .Veldata .v .values , dat .Veldata .u .values , atol = 1e-6 )
234+ npt .assert_allclose (td .Veldata .w .values , - dat .Veldata .w .values , atol = 1e-6 )
235235
236236 # Validation for non-symmetric rotations
237237 td = dat .copy (deep = True )
238238 R = euler2orient (20 , 30 , 60 , units = 'degrees' ) # arbitrary angles
239239 td = set_inst2head_rotmat (td , R )
240+
240241 vel1 = td .vel
241242 # validate that a head->inst rotation occurs (transpose of inst2head_rotmat)
242243 vel2 = np .dot (R , dat .vel )
243244 #assert (vel1 == vel2).all(), "head->inst rotations give unexpeced results."
244- npt .assert_allclose (vel1 .values , vel2 )
245+ npt .assert_allclose (vel1 .values , vel2 , atol = 1e-6 )
245246
246247
247248 def test_rotate_inst2earth_adv (self ):
@@ -255,9 +256,9 @@ def test_rotate_inst2earth_adv(self):
255256 cd = load ('vector_data01_rotate_inst2earth.nc' )
256257 cdm = load ('vector_data_imu01_rotate_inst2earth.nc' )
257258
258- assert_equal (td , cd )
259- assert_equal (tdm , cdm )
260- assert_equal (td , cd )
259+ assert_allclose (td , cd , atol = 1e-6 )
260+ assert_allclose (tdm , cdm , atol = 1e-6 )
261+ assert_allclose (td , cd , atol = 1e-6 )
261262
262263
263264 def test_rotate_earth2inst_adv (self ):
0 commit comments