Changeset 2a52b0e in sasview


Ignore:
Timestamp:
Aug 2, 2017 5:37:27 AM (7 years ago)
Author:
lewis
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:
3eb7bf2
Parents:
be43448
Message:

Remove unit test reliance on IgorReader?

Location:
test/sasdataloader/test
Files:
1 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • test/sasdataloader/test/utest_abs_reader.py

    r5a8cdbb r2a52b0e  
    101101        data = Loader().load("S2-30dq.d1d") 
    102102        self.assertEqual(data.meta_data['loader'], "HFIR 1D") 
    103  
    104  
    105 class igor_reader(unittest.TestCase): 
    106  
    107     def setUp(self): 
    108         # the IgorReader should be able to read this filetype 
    109         # if it can't, stop here. 
    110         reader = IgorReader() 
    111         self.data = reader.read("MAR07232_rest.ASC") 
    112  
    113     def test_igor_checkdata(self): 
    114         """ 
    115             Check the data content to see whether 
    116             it matches the specific file we loaded. 
    117             Check the units too to see whether the 
    118             Data1D defaults changed. Otherwise the 
    119             tests won't pass 
    120         """ 
    121         self.assertEqual(self.data.filename, "MAR07232_rest.ASC") 
    122         self.assertEqual(self.data.meta_data['loader'], "IGOR 2D") 
    123  
    124         self.assertEqual(self.data.source.wavelength_unit, 'A') 
    125         self.assertEqual(self.data.source.wavelength, 8.4) 
    126  
    127         self.assertEqual(self.data.detector[0].distance_unit, 'mm') 
    128         self.assertEqual(self.data.detector[0].distance, 13705) 
    129  
    130         self.assertEqual(self.data.sample.transmission, 0.84357) 
    131  
    132         self.assertEqual(self.data.detector[0].beam_center_unit, 'mm') 
    133         center_x = (68.76 - 1)*5.0 
    134         center_y = (62.47 - 1)*5.0 
    135         self.assertEqual(self.data.detector[0].beam_center.x, center_x) 
    136         self.assertEqual(self.data.detector[0].beam_center.y, center_y) 
    137  
    138         self.assertEqual(self.data.I_unit, '1/cm') 
    139         # 3 points should be suffcient to check that the data is in column 
    140         # major order. 
    141         np.testing.assert_almost_equal(self.data.data[0:3], 
    142                                        [0.279783, 0.28951, 0.167634]) 
    143         np.testing.assert_almost_equal(self.data.qx_data[0:3], 
    144                                        [-0.01849072, -0.01821785, -0.01794498]) 
    145         np.testing.assert_almost_equal(self.data.qy_data[0:3], 
    146                                        [-0.01677435, -0.01677435, -0.01677435]) 
    147  
    148     def test_generic_loader(self): 
    149         # the generic loader should direct the file to IgorReader as well 
    150         data = Loader().load("MAR07232_rest.ASC") 
    151         self.assertEqual(data.meta_data['loader'], "IGOR 2D") 
    152  
    153103 
    154104class DanseReaderTests(unittest.TestCase): 
  • test/sasdataloader/test/utest_averaging.py

    r5a8cdbb r2a52b0e  
    103103    def setUp(self): 
    104104        filepath = os.path.join(os.path.dirname( 
    105             os.path.realpath(__file__)), 'MAR07232_rest.ASC') 
    106         self.data = Loader().load(filepath) 
     105            os.path.realpath(__file__)), 'MAR07232_rest.h5') 
     106        self.data = Loader().load(filepath)[0] 
    107107 
    108108    def test_ring(self): 
     
    119119        filepath = os.path.join(os.path.dirname( 
    120120            os.path.realpath(__file__)), 'ring_testdata.txt') 
    121         answer = Loader().load(filepath) 
     121        answer = Loader().load(filepath)[0] 
    122122 
    123123        for i in range(r.nbins_phi - 1): 
     
    139139        filepath = os.path.join(os.path.dirname( 
    140140            os.path.realpath(__file__)), 'avg_testdata.txt') 
    141         answer = Loader().load(filepath) 
     141        answer = Loader().load(filepath)[0] 
    142142        for i in range(r.nbins_phi): 
    143143            self.assertAlmostEqual(o.x[i], answer.x[i], 4) 
     
    175175        filepath = os.path.join(os.path.dirname( 
    176176            os.path.realpath(__file__)), 'slabx_testdata.txt') 
    177         answer = Loader().load(filepath) 
     177        answer = Loader().load(filepath)[0] 
    178178        for i in range(len(o.x)): 
    179179            self.assertAlmostEqual(o.x[i], answer.x[i], 4) 
     
    194194        filepath = os.path.join(os.path.dirname( 
    195195            os.path.realpath(__file__)), 'slaby_testdata.txt') 
    196         answer = Loader().load(filepath) 
     196        answer = Loader().load(filepath)[0] 
    197197        for i in range(len(o.x)): 
    198198            self.assertAlmostEqual(o.x[i], answer.x[i], 4) 
     
    221221        filepath = os.path.join(os.path.dirname( 
    222222            os.path.realpath(__file__)), 'ring_testdata.txt') 
    223         answer = Loader().load(filepath) 
     223        answer = Loader().load(filepath)[0] 
    224224        for i in range(len(o.x)): 
    225225            self.assertAlmostEqual(o.x[i], answer.x[i], 4) 
     
    239239        filepath = os.path.join(os.path.dirname( 
    240240            os.path.realpath(__file__)), 'sectorphi_testdata.txt') 
    241         answer = Loader().load(filepath) 
     241        answer = Loader().load(filepath)[0] 
    242242        for i in range(len(o.x)): 
    243243            self.assertAlmostEqual(o.x[i], answer.x[i], 4) 
     
    257257        filepath = os.path.join(os.path.dirname( 
    258258            os.path.realpath(__file__)), 'sectorq_testdata.txt') 
    259         answer = Loader().load(filepath) 
     259        answer = Loader().load(filepath)[0] 
    260260        for i in range(len(o.x)): 
    261261            self.assertAlmostEqual(o.x[i], answer.x[i], 4) 
Note: See TracChangeset for help on using the changeset viewer.