Changeset fe78c7b in sasview for DataLoader/test


Ignore:
Timestamp:
Sep 5, 2009 11:45:29 AM (15 years ago)
Author:
Mathieu Doucet <doucetm@…>
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.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7d8c41f
Parents:
4deaec6
Message:

DataLoader?: exception no longer raised when units are wrong for an entry; the entry is not loaded and an error is logged instead. Loader info is now stored.

Location:
DataLoader/test
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/test/utest_abs_reader.py

    rd00f8ff rfe78c7b  
    1313     
    1414    def setUp(self): 
    15         self.data = Loader().load("jan08002.ABS") 
     15        from DataLoader.readers.abs_reader import Reader 
     16        self.data = Reader().read("jan08002.ABS") 
    1617         
    1718    def test_checkdata(self): 
     
    2425        """ 
    2526        self.assertEqual(self.data.filename, "jan08002.ABS") 
     27        self.assertEqual(self.data.meta_data['loader'], "IGOR 1D") 
    2628         
    2729        self.assertEqual(self.data.source.wavelength_unit, 'A') 
     
    6971        """ 
    7072        self.assertEqual(self.data.filename, "S2-30dq.d1d") 
     73        # THIS FILE FORMAT IS CURRENTLY READ BY THE ASCII READER 
     74        self.assertEqual(self.data.meta_data['loader'], "ASCII") 
    7175        self.assertEqual(len(self.data.x), 134) 
    7276        self.assertEqual(len(self.data.y), 134) 
     
    9397        """ 
    9498        self.assertEqual(self.data.filename, "MAR07232_rest.ASC") 
     99        self.assertEqual(self.data.meta_data['loader'], "IGOR 2D") 
    95100         
    96101        self.assertEqual(self.data.source.wavelength_unit, 'A') 
     
    127132        """ 
    128133        self.assertEqual(self.data.filename, "MP_New.sans") 
     134        self.assertEqual(self.data.meta_data['loader'], "DANSE") 
    129135         
    130136        self.assertEqual(self.data.source.wavelength_unit, 'A') 
     
    169175         
    170176        self.assertEqual(self.data.run[0], "1234") 
     177        self.assertEqual(self.data.meta_data['loader'], "CanSAS 1D") 
     178        self.assertEqual(len(self.data.errors), 0) 
    171179         
    172180        # Data 
     
    325333        self._checkdata() 
    326334         
     335    def test_badunits(self): 
     336        """ 
     337            Check units. 
     338            Note that not all units are available. 
     339        """ 
     340        filename = "cansas1d_badunits.xml" 
     341        self.data = Loader().load(filename) 
     342        self.assertEqual(self.data.filename, filename) 
     343        # The followed should not have been loaded 
     344        self.assertEqual(self.data.sample.thickness, None) 
     345        # This one should 
     346        self.assertEqual(self.data.sample.transmission, 0.327) 
     347         
     348        self.assertEqual(self.data.meta_data['loader'], "CanSAS 1D") 
     349        self.assertEqual(len(self.data.errors), 1) 
     350         
    327351         
    328352    def test_slits(self): 
     
    356380 
    357381if __name__ == '__main__': 
     382    import logging 
     383    logging.basicConfig(level=logging.INFO, 
     384                        format='%(asctime)s %(levelname)s %(message)s', 
     385                        filename='utest_abs_reader.log', 
     386                        filemode='w') 
    358387    unittest.main() 
    359388    
  • DataLoader/test/utest_ascii.py

    raf76bd9 rfe78c7b  
    2424        self.assertEqual(f.x[0],0.002618) 
    2525        self.assertEqual(f.x[9],0.0497) 
     26         
     27        self.assertEqual(f.meta_data['loader'],"ASCII") 
    2628         
    2729    def test_truncated_1(self): 
Note: See TracChangeset for help on using the changeset viewer.