- Timestamp:
- Sep 17, 2018 2:44:32 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
- Children:
- 926ece5
- Parents:
- a78446ce
- Location:
- test/sasdataloader/test
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
test/sasdataloader/test/utest_abs_reader.py
r35ac8df rf4e2f22 80 80 data_cor = Loader().load(find("sam14_cor.cor")) 81 81 for i in range(0, len(data_abs) - 1): 82 self.assertEqual s(data_abs.x[i], data_cor.x[i])83 self.assertEqual s(data_abs.y[i], data_cor.y[i])84 self.assertEqual s(data_abs.dxl[i], data_cor.dxl[i])85 self.assertEqual s(data_abs.dxw[i], data_cor.dxw[i])82 self.assertEqual(data_abs.x[i], data_cor.x[i]) 83 self.assertEqual(data_abs.y[i], data_cor.y[i]) 84 self.assertEqual(data_abs.dxl[i], data_cor.dxl[i]) 85 self.assertEqual(data_abs.dxw[i], data_cor.dxw[i]) 86 86 self.assertTrue(data_abs.dxl > 0) 87 87 -
test/sasdataloader/test/utest_averaging.py
r7fd5e2a rf4e2f22 106 106 107 107 def setUp(self): 108 filepath = find('test_data //MAR07232_rest.h5')108 filepath = find('test_data' + os.sep + 'MAR07232_rest.h5') 109 109 self.data_list = Loader().load(filepath) 110 110 self.data = self.data_list[0] … … 121 121 122 122 o = r(self.data) 123 filepath = find('test_data //ring_testdata.txt')123 filepath = find('test_data' + os.sep + 'ring_testdata.txt') 124 124 answer_list = Loader().load(filepath) 125 125 answer = answer_list[0] … … 142 142 o = r(self.data) 143 143 144 filepath = find('test_data //avg_testdata.txt')144 filepath = find('test_data' + os.sep + 'avg_testdata.txt') 145 145 answer = Loader().load(filepath)[0] 146 146 for i in range(r.nbins_phi): … … 177 177 o = r(self.data) 178 178 179 filepath = find('test_data //slabx_testdata.txt')179 filepath = find('test_data' + os.sep + 'slabx_testdata.txt') 180 180 answer = Loader().load(filepath)[0] 181 181 for i in range(len(o.x)): … … 195 195 o = r(self.data) 196 196 197 filepath = find('test_data //slaby_testdata.txt')197 filepath = find('test_data' + os.sep + 'slaby_testdata.txt') 198 198 answer = Loader().load(filepath)[0] 199 199 for i in range(len(o.x)): … … 221 221 o = r(self.data) 222 222 223 filepath = find('test_data //ring_testdata.txt')223 filepath = find('test_data' + os.sep + 'ring_testdata.txt') 224 224 answer = Loader().load(filepath)[0] 225 225 for i in range(len(o.x)): … … 238 238 o = r(self.data) 239 239 240 filepath = find('test_data //sectorphi_testdata.txt')240 filepath = find('test_data' + os.sep + 'sectorphi_testdata.txt') 241 241 answer = Loader().load(filepath)[0] 242 242 for i in range(len(o.x)): … … 255 255 o = r(self.data) 256 256 257 filepath = find('test_data //sectorq_testdata.txt')257 filepath = find('test_data' + os.sep + 'sectorq_testdata.txt') 258 258 answer = Loader().load(filepath)[0] 259 259 for i in range(len(o.x)): -
test/sasdataloader/test/utest_cansas.py
r2ca5d57b rf4e2f22 256 256 self.datafile_basic = find("simpleexamplefile.h5") 257 257 self.datafile_multiplesasentry = find( 258 "test_data //nxcansas_1Dand2D_multisasentry.h5")258 "test_data" + os.sep + "nxcansas_1Dand2D_multisasentry.h5") 259 259 self.datafile_multiplesasdata = find( 260 "test_data //nxcansas_1Dand2D_multisasdata.h5")260 "test_data" + os.sep + "nxcansas_1Dand2D_multisasdata.h5") 261 261 self.datafile_multiplesasdata_multiplesasentry = find( 262 "test_data //nxcansas_1Dand2D_multisasentry_multisasdata.h5")262 "test_data" + os.sep + "nxcansas_1Dand2D_multisasentry_multisasdata.h5") 263 263 264 264 def test_real_data(self): … … 305 305 306 306 def _check_multiple_data(self, data): 307 self.assert True(data.title =="MH4_5deg_16T_SLOW")308 self.assert True(data.run[0] =='33837')309 self.assert True(len(data.run) ==1)310 self.assert True(data.instrument =="SANS2D")311 self.assert True(data.source.radiation =="Spallation Neutron Source")312 self.assert True(len(data.detector) ==2)307 self.assertEqual(data.title, "MH4_5deg_16T_SLOW") 308 self.assertEqual(data.run[0], '33837') 309 self.assertEqual(len(data.run), 1) 310 self.assertEqual(data.instrument, "SANS2D") 311 self.assertEqual(data.source.radiation, "Spallation Neutron Source") 312 self.assertEqual(len(data.detector), 2) 313 313 self.assertTrue(data.detector[0].name == "rear-detector" 314 314 or data.detector[1].name == "rear-detector") … … 317 317 self.assertAlmostEqual(data.detector[0].distance + 318 318 data.detector[1].distance, 7230.54, 2) 319 self.assert True(data.detector[0].distance_unit =='mm')320 self.assert True(len(data.trans_spectrum) ==1)319 self.assertEqual(data.detector[0].distance_unit, 'mm') 320 self.assertEqual(len(data.trans_spectrum), 1) 321 321 322 322 def _check_1d_data(self, data): 323 self.assert True(len(data.x) ==66)324 self.assert True(len(data.x) ==len(data.y))325 self.assert True(data.dy[10] ==0.207214)326 self.assert True(data.y[10] ==24.1939)327 self.assert True(data.x[10] ==0.00898113)323 self.assertEqual(len(data.x), 66) 324 self.assertEqual(len(data.x), len(data.y)) 325 self.assertAlmostEqual(data.dy[10], 0.207214) 326 self.assertAlmostEqual(data.y[10], 24.1939) 327 self.assertAlmostEqual(data.x[10], 0.00898113) 328 328 329 329 def _check_2d_data(self, data): 330 330 self.assertTrue(isinstance(data, Data2D)) 331 self.assert True(len(data.q_data) ==150*150)332 self.assert True(len(data.q_data) ==len(data.data))331 self.assertEqual(len(data.q_data), 150*150) 332 self.assertEqual(len(data.q_data), len(data.data)) 333 333 self.assertAlmostEqual(data.err_data[10], 0.186723989418) 334 334 self.assertAlmostEqual(data.data[10], 0.465181) … … 337 337 338 338 def _check_example_data(self, data): 339 self.assert True(data.title =="")340 self.assert True(data.x.size ==100)341 self.assert True(data._xunit =="A^{-1}")342 self.assert True(data._yunit =="cm^{-1}")343 self.assert True(data.y.size ==100)339 self.assertEqual(data.title, "") 340 self.assertEqual(data.x.size, 100) 341 self.assertEqual(data._xunit, "A^{-1}") 342 self.assertEqual(data._yunit, "cm^{-1}") 343 self.assertEqual(data.y.size, 100) 344 344 self.assertAlmostEqual(data.y[40], 0.952749011516985) 345 345 self.assertAlmostEqual(data.x[40], 0.3834415188257777) -
test/sasdataloader/test/utest_generic_file_reader_class.py
r4a8d55c rf4e2f22 45 45 last_f = f[0] 46 46 if hasattr(last_f, "errors"): 47 self.assertEqual s(len(last_f.errors), 1)47 self.assertEqual(len(last_f.errors), 1) 48 48 else: 49 49 self.fail("Errors did not propogate to the file properly.") … … 51 51 def test_same_file_unknown_extensions(self): 52 52 # Five files, all with the same content, but different file extensions 53 no_ext = find("test_data //TestExtensions")54 not_xml = find("test_data //TestExtensions.notxml")53 no_ext = find("test_data" + os.sep + "TestExtensions") 54 not_xml = find("test_data" + os.sep + "TestExtensions.notxml") 55 55 # Deprecated extensions 56 asc_dep = find("test_data //TestExtensions.asc")57 nxs_dep = find("test_data //TestExtensions.nxs")56 asc_dep = find("test_data" + os.sep + "TestExtensions.asc") 57 nxs_dep = find("test_data" + os.sep + "TestExtensions.nxs") 58 58 # Native extension as a baseline 59 xml_native = find("test_data //TestExtensions.xml")59 xml_native = find("test_data" + os.sep + "TestExtensions.xml") 60 60 # Load the files and check contents 61 61 no_ext_load = self.generic_reader.load(no_ext) … … 70 70 self.check_unknown_extension(xml_load[0]) 71 71 # Be sure the deprecation warning is passed with the file 72 self.assertEqual s(len(asc_load[0].errors), 1)73 self.assertEqual s(len(nxs_load[0].errors), 1)72 self.assertEqual(len(asc_load[0].errors), 1) 73 self.assertEqual(len(nxs_load[0].errors), 1) 74 74 75 75 def check_unknown_extension(self, data): 76 76 self.assertTrue(isinstance(data, Data1D)) 77 self.assertEqual s(len(data.x), 138)78 self.assertEqual s(data.sample.ID, "TK49 c10_SANS")79 self.assertEqual s(data.meta_data["loader"], "CanSAS XML 1D")77 self.assertEqual(len(data.x), 138) 78 self.assertEqual(data.sample.ID, "TK49 c10_SANS") 79 self.assertEqual(data.meta_data["loader"], "CanSAS XML 1D") 80 80 81 81 def tearDown(self): -
test/sasdataloader/test/utest_sesans.py
rf53d684 rf4e2f22 25 25 Test .SES in the full loader to make sure that the file type is correctly accepted 26 26 """ 27 file = Loader().load(find("sesans_examples/sphere2micron.ses")) 27 file = Loader().load(find("sesans_examples" + os.sep + 28 "sphere2micron.ses")) 28 29 f = file[0] 29 30 # self.assertEqual(f, 5) … … 44 45 Test .SES loading on a TOF dataset 45 46 """ 46 file = self.loader(find("sesans_examples /sphere_isis.ses"))47 file = self.loader(find("sesans_examples" + os.sep + "sphere_isis.ses")) 47 48 f = file[0] 48 49 self.assertEqual(len(file), 1) … … 62 63 FileContentsException, 63 64 self.loader, 64 find("sesans_examples /sesans_no_data.ses"))65 find("sesans_examples" + os.sep + "sesans_no_data.ses")) 65 66 66 67 def test_sesans_no_spin_echo_unit(self): … … 71 72 FileContentsException, 72 73 self.loader, 73 find("sesans_examples /no_spin_echo_unit.ses"))74 find("sesans_examples" + os.sep + "no_spin_echo_unit.ses")) 74 75 75 76 def test_sesans_future_version(self): … … 80 81 FileContentsException, 81 82 self.loader, 82 find("sesans_examples /next_gen.ses"))83 find("sesans_examples" + os.sep + "next_gen.ses")) 83 84 84 85 def test_sesans_mandatory_headers(self): … … 89 90 FileContentsException, 90 91 self.loader, 91 find("sesans_examples /no_wavelength.ses"))92 find("sesans_examples" + os.sep + "no_wavelength.ses")) 92 93 93 94 def test_sesans_columns_match_headers(self): … … 98 99 FileContentsException, 99 100 self.loader, 100 find("sesans_examples /too_many_headers.ses"))101 find("sesans_examples" + os.sep + "too_many_headers.ses")) 101 102 102 103 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.