Changeset e801a4e in sasview


Ignore:
Timestamp:
Apr 9, 2017 5:24:21 AM (7 years ago)
Author:
Adam Washington <adam.washington@…>
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:
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.