Changes in / [658dd57:c00a797a] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/sasdataloader/test/utest_abs_reader.py
rc551bb3 raaf5e49 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 AbsReader12 from sas.sascalc.dataloader.readers.hfir1d_reader import Reader as HFIRReader13 from sas.sascalc.dataloader.readers.danse_reader import Reader as DANSEReader14 from sas.sascalc.dataloader.readers.cansas_reader import Reader as CANSASReader15 16 11 from sas.sascalc.dataloader.data_info import Data1D 17 12 18 13 import os.path 19 14 20 21 15 class abs_reader(unittest.TestCase): 22 16 23 17 def setUp(self): 24 reader = AbsReader()25 self.data = reader.read("jan08002.ABS")26 18 from sas.sascalc.dataloader.readers.abs_reader import Reader 19 self.data = Reader().read("jan08002.ABS") 20 27 21 def test_abs_checkdata(self): 28 22 """ … … 68 62 def test_checkdata2(self): 69 63 self.assertEqual(self.data.dy[126], 1) 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 64 77 65 class hfir_reader(unittest.TestCase): 78 66 79 67 def setUp(self): 80 reader = HFIRReader() 81 self.data = reader.read("S2-30dq.d1d") 82 68 self.data = Loader().load("S2-30dq.d1d") 69 83 70 def test_hfir_checkdata(self): 84 71 """ … … 97 84 self.assertEqual(self.data.dy[1], 0.000315) 98 85 self.assertEqual(self.data.dx[1], 0.008249) 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 86 105 87 106 88 class igor_reader(unittest.TestCase): … … 156 138 157 139 def setUp(self): 158 reader = DANSEReader() 159 self.data = reader.read("MP_New.sans") 140 self.data = Loader().load("MP_New.sans") 160 141 161 142 def test_checkdata(self): … … 191 172 self.assertEqual(self.data.err_data[2], 2.06313) 192 173 193 def test_generic_loader(self):194 # the generic loader should work as well195 data = Loader().load("MP_New.sans")196 self.assertEqual(data.meta_data['loader'], "DANSE")197 198 174 199 175 class cansas_reader(unittest.TestCase): 200 176 201 177 def setUp(self): 202 reader = CANSASReader() 203 data = reader.read("cansas1d.xml") 178 data = Loader().load("cansas1d.xml") 204 179 self.data = data[0] 205 206 def test_generic_loader(self): 207 # the generic loader should work as well 208 data = Loader().load("cansas1d.xml") 209 self.assertEqual(data[0].meta_data['loader'], "CanSAS XML 1D") 210 180 211 181 def test_cansas_checkdata(self): 212 182 self.assertEqual(self.data.filename, "cansas1d.xml") … … 221 191 tests won't pass 222 192 """ 193 223 194 self.assertEqual(self.data.run[0], "1234") 224 195 self.assertEqual(self.data.meta_data['loader'], "CanSAS XML 1D") … … 294 265 self.assertEqual(item.distance_unit,'mm') 295 266 296 if item.size.x ==50 \297 and item.distance ==11000.0 \298 and item.name =='source' \299 and item.type =='radius':267 if item.size.x==50 \ 268 and item.distance==11000.0 \ 269 and item.name=='source' \ 270 and item.type=='radius': 300 271 _found1 = True 301 elif item.size.x ==1.0 \302 and item.name =='sample' \303 and item.type =='radius':272 elif item.size.x==1.0 \ 273 and item.name=='sample' \ 274 and item.type=='radius': 304 275 _found2 = True 305 276 306 if _found1 == False or _found2 ==False:277 if _found1==False or _found2==False: 307 278 raise RuntimeError, "Could not find all data %s %s" % (_found1, _found2) 308 279 … … 341 312 print(item.term) 342 313 for t in item.term: 343 if (t['name'] == "ABS:DSTAND"344 and t['unit'] == 'mm'345 and float(t['value']) == 1.0):314 if t['name']=="ABS:DSTAND" \ 315 and t['unit']=='mm' \ 316 and float(t['value'])==1.0: 346 317 _found_term2 = True 347 elif (t['name'] == "radialstep"348 and t['unit'] == 'mm'349 and float(t['value']) == 10.0):318 elif t['name']=="radialstep" \ 319 and t['unit']=='mm' \ 320 and float(t['value'])==10.0: 350 321 _found_term1 = True 351 322 352 if _found_term1 == False or _found_term2 == False: 353 raise RuntimeError, "Could not find all process terms %s %s" % (_found_term1, _found_term2) 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 354 328 355 329 def test_writer(self): 356 r = CANSASReader() 357 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 358 336 filename = "write_test.xml" 359 337 r.write(filename, self.data) … … 371 349 """ 372 350 filename = "cansas1d_units.xml" 373 data = CANSASReader().read(filename)351 data = Loader().load(filename) 374 352 self.data = data[0] 375 353 self.assertEqual(self.data.filename, filename) … … 382 360 """ 383 361 filename = "cansas1d_badunits.xml" 384 data = CANSASReader().read(filename)362 data = Loader().load(filename) 385 363 self.data = data[0] 386 364 self.assertEqual(self.data.filename, filename) … … 393 371 print(self.data.errors) 394 372 self.assertEqual(len(self.data.errors), 1) 395 373 374 396 375 def test_slits(self): 397 376 """ … … 399 378 """ 400 379 filename = "cansas1d_slit.xml" 401 data = CANSASReader().read(filename)380 data = Loader().load(filename) 402 381 self.data = data[0] 403 382 self.assertEqual(self.data.filename, filename) … … 421 400 self.assertEqual(self.data.run_name['1234'], 'run name') 422 401 self.assertEqual(self.data.title, "Test title") 423 402 403 424 404 425 405 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.