- Timestamp:
- May 1, 2017 6:35:46 PM (8 years ago)
- Children:
- df29bc2
- Parents:
- 0cc77d8 (diff), 658dd57 (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:
- Paul Kienzle <pkienzle@…> (05/01/17 18:35:46)
- git-committer:
- GitHub <noreply@…> (05/01/17 18:35:46)
- Location:
- test
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
test/sasdataloader/test/utest_abs_reader.py
r0cc77d8 r733cdcd 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 not _found1 or not _found2: 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:352 if not _found_term1 or not _found_term2: 324 353 raise RuntimeError("Could not find all process terms %s %s" % (_found_term1, _found_term2)) 325 326 327 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__': -
test/sasdataloader/plugins/test_reader.py
raaf5e49 r0cc77d8 40 40 input_f = open(path,'r') 41 41 except : 42 raise RuntimeError , "ascii_reader: cannot open %s" % path42 raise RuntimeError("ascii_reader: cannot open %s" % path) 43 43 buff = input_f.read() 44 44 lines = buff.split('\n') … … 55 55 return output 56 56 else: 57 raise RuntimeError , "%s is not a file" % path57 raise RuntimeError("%s is not a file" % path) 58 58 return None 59 59 -
test/sasrealspace/test/utest_oriented.py
raaf5e49 r0cc77d8 243 243 except: 244 244 print("Error", ana_val, sim_val, sim_val/ana_val) 245 raise sys.exc_type , sys.exc_value245 raise sys.exc_type(sys.exc_value) 246 246 247 247 class TestCoreShell(unittest.TestCase): … … 397 397 except: 398 398 print("Error", ana_val, sim_val, sim_val/ana_val) 399 raise sys.exc_type , sys.exc_value399 raise sys.exc_type(sys.exc_value) 400 400 401 401 def testRunXY_float(self): … … 408 408 self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 ) 409 409 except: 410 raise sys.exc_type(sys.exc_value) 410 411 print("Error", ana_val, sim_val, sim_val/ana_val) 411 raise sys.exc_type , sys.exc_value412 raise sys.exc_type(sys.exc_value) 412 413 413 414 def testRun_float(self): … … 421 422 except: 422 423 print("Error", ana_val, sim_val, sim_val/ana_val) 423 raise sys.exc_type , sys.exc_value424 raise sys.exc_type(sys.exc_value) 424 425 425 426 def testRun_list(self): … … 433 434 except: 434 435 print("Error", ana_val, sim_val, sim_val/ana_val) 435 raise sys.exc_type , sys.exc_value436 raise sys.exc_type(sys.exc_value) 436 437 437 438 class TestParamChange(unittest.TestCase):
Note: See TracChangeset
for help on using the changeset viewer.