Changeset 658dd57 in sasview
- Timestamp:
- May 1, 2017 5:56:23 PM (8 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- b6b81a3, fca1f50, 7b15990, 2f17d40, fadb757, df29bc2, 733cdcd
- Parents:
- c00a797a (diff), c551bb3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Andrew Nelson <andyfaff@…> (05/01/17 17:56:23)
- git-committer:
- GitHub <noreply@…> (05/01/17 17:56:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/sasdataloader/test/utest_abs_reader.py
raaf5e49 rc551bb3 9 9 from sas.sascalc.dataloader.loader import Loader 10 10 from sas.sascalc.dataloader.readers.IgorReader import Reader as IgorReader 11 from sas.sascalc.dataloader.readers.abs_reader import Reader as AbsReader 12 from sas.sascalc.dataloader.readers.hfir1d_reader import Reader as HFIRReader 13 from sas.sascalc.dataloader.readers.danse_reader import Reader as DANSEReader 14 from sas.sascalc.dataloader.readers.cansas_reader import Reader as CANSASReader 15 11 16 from sas.sascalc.dataloader.data_info import Data1D 12 17 13 18 import os.path 14 19 20 15 21 class abs_reader(unittest.TestCase): 16 22 17 23 def setUp(self): 18 from sas.sascalc.dataloader.readers.abs_reader import Reader19 self.data = Reader().read("jan08002.ABS")20 24 reader = AbsReader() 25 self.data = reader.read("jan08002.ABS") 26 21 27 def test_abs_checkdata(self): 22 28 """ … … 62 68 def test_checkdata2(self): 63 69 self.assertEqual(self.data.dy[126], 1) 64 70 71 def test_generic_loader(self): 72 # the generic loader should work as well 73 data = Loader().load("jan08002.ABS") 74 self.assertEqual(data.meta_data['loader'], "IGOR 1D") 75 76 65 77 class hfir_reader(unittest.TestCase): 66 78 67 79 def setUp(self): 68 self.data = Loader().load("S2-30dq.d1d") 69 80 reader = HFIRReader() 81 self.data = reader.read("S2-30dq.d1d") 82 70 83 def test_hfir_checkdata(self): 71 84 """ … … 84 97 self.assertEqual(self.data.dy[1], 0.000315) 85 98 self.assertEqual(self.data.dx[1], 0.008249) 86 99 100 def test_generic_loader(self): 101 # the generic loader should work as well 102 data = Loader().load("S2-30dq.d1d") 103 self.assertEqual(data.meta_data['loader'], "HFIR 1D") 104 87 105 88 106 class igor_reader(unittest.TestCase): … … 138 156 139 157 def setUp(self): 140 self.data = Loader().load("MP_New.sans") 158 reader = DANSEReader() 159 self.data = reader.read("MP_New.sans") 141 160 142 161 def test_checkdata(self): … … 172 191 self.assertEqual(self.data.err_data[2], 2.06313) 173 192 193 def test_generic_loader(self): 194 # the generic loader should work as well 195 data = Loader().load("MP_New.sans") 196 self.assertEqual(data.meta_data['loader'], "DANSE") 197 174 198 175 199 class cansas_reader(unittest.TestCase): 176 200 177 201 def setUp(self): 202 reader = CANSASReader() 203 data = reader.read("cansas1d.xml") 204 self.data = data[0] 205 206 def test_generic_loader(self): 207 # the generic loader should work as well 178 208 data = Loader().load("cansas1d.xml") 179 self. data = data[0]180 209 self.assertEqual(data[0].meta_data['loader'], "CanSAS XML 1D") 210 181 211 def test_cansas_checkdata(self): 182 212 self.assertEqual(self.data.filename, "cansas1d.xml") … … 191 221 tests won't pass 192 222 """ 193 194 223 self.assertEqual(self.data.run[0], "1234") 195 224 self.assertEqual(self.data.meta_data['loader'], "CanSAS XML 1D") … … 265 294 self.assertEqual(item.distance_unit,'mm') 266 295 267 if item.size.x ==50 \268 and item.distance ==11000.0 \269 and item.name =='source' \270 and item.type =='radius':296 if item.size.x == 50 \ 297 and item.distance == 11000.0 \ 298 and item.name == 'source' \ 299 and item.type == 'radius': 271 300 _found1 = True 272 elif item.size.x ==1.0 \273 and item.name =='sample' \274 and item.type =='radius':301 elif item.size.x == 1.0 \ 302 and item.name == 'sample' \ 303 and item.type == 'radius': 275 304 _found2 = True 276 305 277 if _found1 ==False or _found2==False:306 if _found1 == False or _found2 == False: 278 307 raise RuntimeError, "Could not find all data %s %s" % (_found1, _found2) 279 308 … … 312 341 print(item.term) 313 342 for t in item.term: 314 if t['name']=="ABS:DSTAND" \315 and t['unit'] =='mm' \316 and float(t['value']) ==1.0:343 if (t['name'] == "ABS:DSTAND" 344 and t['unit'] == 'mm' 345 and float(t['value']) == 1.0): 317 346 _found_term2 = True 318 elif t['name']=="radialstep" \319 and t['unit']=='mm' \320 and float(t['value'])==10.0:347 elif (t['name'] == "radialstep" 348 and t['unit'] == 'mm' 349 and float(t['value']) == 10.0): 321 350 _found_term1 = True 322 351 323 if _found_term1==False or _found_term2==False: 324 raise RuntimeError, "Could not find all process terms %s %s" % (_found_term1, _found_term2) 325 326 327 352 if _found_term1 == False or _found_term2 == False: 353 raise RuntimeError, "Could not find all process terms %s %s" % (_found_term1, _found_term2) 328 354 329 355 def test_writer(self): 330 from sas.sascalc.dataloader.readers.cansas_reader import Reader 331 r = Reader() 332 x = np.ones(5) 333 y = np.ones(5) 334 dy = np.ones(5) 335 356 r = CANSASReader() 357 336 358 filename = "write_test.xml" 337 359 r.write(filename, self.data) … … 349 371 """ 350 372 filename = "cansas1d_units.xml" 351 data = Loader().load(filename)373 data = CANSASReader().read(filename) 352 374 self.data = data[0] 353 375 self.assertEqual(self.data.filename, filename) … … 360 382 """ 361 383 filename = "cansas1d_badunits.xml" 362 data = Loader().load(filename)384 data = CANSASReader().read(filename) 363 385 self.data = data[0] 364 386 self.assertEqual(self.data.filename, filename) … … 371 393 print(self.data.errors) 372 394 self.assertEqual(len(self.data.errors), 1) 373 374 395 375 396 def test_slits(self): 376 397 """ … … 378 399 """ 379 400 filename = "cansas1d_slit.xml" 380 data = Loader().load(filename)401 data = CANSASReader().read(filename) 381 402 self.data = data[0] 382 403 self.assertEqual(self.data.filename, filename) … … 400 421 self.assertEqual(self.data.run_name['1234'], 'run name') 401 422 self.assertEqual(self.data.title, "Test title") 402 403 423 404 424 405 425 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.