Changeset e801a4e in sasview


Ignore:
Timestamp:
Apr 9, 2017 5:24:21 AM (6 months ago)
Author:
Adam Washington <adam.washington@…>
Branches:
master, ESS_GUI, ESS_GUI_SasView245, costrafo411, py3, ticket-853-fit-gui-to-calc, ticket-869, ticket-887-reorg, ticket-915, ticket-947-sasmodels-docs, ticket-976, unittest-saveload
Children:
35cf5c0
Parents:
a81af92
Message:

Test that SESANS files insist on proper headers

Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    ra81af92 re801a4e  
    8686            headers = input_f.readline().split() 
    8787 
     88            self._insist_header(headers, "SpinEchoLength") 
     89            self._insist_header(headers, "Depolarisation") 
     90            self._insist_header(headers, "Depolarisation_error") 
     91            self._insist_header(headers, "Wavelength") 
     92 
    8893            data = np.loadtxt(input_f) 
    8994            if data.size < 1: 
     
    141146 
    142147    @staticmethod 
     148    def _insist_header(headers, name): 
     149        if name not in headers: 
     150            raise RuntimeError( 
     151                "Missing {} column in spin echo data".format(name)) 
     152 
     153    @staticmethod 
    143154    def _unit_conversion(value, value_unit, default_unit): 
    144155        """ 
  • test/sasdataloader/test/utest_sesans.py

    ra81af92 re801a4e  
    7878            self.loader, 
    7979            "sesans_examples/next_gen.ses") 
     80 
     81    def test_sesans_mandatory_headers(self): 
     82        """ 
     83            Confirm that sesans files throw an exception if one of the mandator headers is missing. 
     84        """ 
     85        self.assertRaises( 
     86            RuntimeError, 
     87            self.loader, 
     88            "sesans_examples/no_wavelength.ses") 
     89 
    8090if __name__ == "__main__": 
    8191    unittest.main() 
Note: See TracChangeset for help on using the changeset viewer.