Changeset 76cd1ae in sasview for test


Ignore:
Timestamp:
Jan 14, 2014 3:53:36 PM (11 years ago)
Author:
Jeff Krzywon <jeffery.krzywon@…>
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:
16bd5ca
Parents:
083e993
Message:

Fix for the datainfo window not loading and bug fixes for the cansas data reader.

Fixes/changes:
(1) datainfo window is now loading for every data file I can test
(2) transmission spectrum information (but not data) is listed in datainfo window
(3) more than one transmission spectra can be loaded for each Data1D object
(4) fixed a bug in the cansas reader that allowed any file to be loaded as data if and only if another data file was already loaded
(5) fixed the cansas writer to include transmission spectrum data and output data in strict canSAS format
(6) increased the pylint score of cansas_constants.py to above 7
(7) increased the pylint score for all files I have modified

Location:
test/sansdataloader/test
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • test/sansdataloader/test/utest_cansas.py

    r3f484b0 r76cd1ae  
    3838        self.isis_1_1 = "ISIS_1_1.xml" 
    3939        self.isis_1_1_notrans = "ISIS_1_1_notrans.xml" 
     40        self.isis_1_1_doubletrans = "ISIS_1_1_doubletrans.xml" 
    4041        self.schema_1_0 = "cansas1d_v1_0.xsd" 
    4142        self.schema_1_1 = "cansas1d_v1_1.xsd" 
     
    7778            self.assertFalse(valid) 
    7879             
     80             
     81    def _check_data(self, data): 
     82        self.assertTrue(data.title == "TK49 c10_SANS") 
     83        self.assertTrue(data.x.size == 138) 
     84        self.assertTrue(len(data.meta_data) == 2) 
     85        self.assertTrue(data.detector[0].distance_unit == "mm") 
     86        self.assertTrue(data.detector[1].distance_unit == "mm") 
     87        self.assertTrue(data.detector[0].name == "HAB") 
     88        self.assertTrue(data.detector[1].name == "main-detector-bank") 
     89        self.assertTrue(data.detector[0].distance == 575.0) 
     90        self.assertTrue(data.detector[1].distance == 4145.02) 
     91        spectrum = data.trans_spectrum[0] 
     92        self.assertTrue(len(spectrum.wavelength) == 138) 
     93        self.assertTrue(data.process[0].name == "Mantid generated CanSAS1D XML") 
     94         
    7995         
    8096    def test_cansas_xml(self): 
     
    8399        valid = xmlreader.validateXML() 
    84100        self.assertTrue(valid) 
    85         reader = Reader() 
    86         dataloader = reader.read(self.isis_1_1) 
    87         for data in dataloader: 
    88             self.assertTrue(data.title == "TK49 c10_SANS") 
    89             self.assertTrue(data.x.size == 138) 
    90             self.assertTrue(len(data.meta_data) == 2) 
    91             self.assertTrue(data.detector[0].distance_unit == "mm") 
    92             reader.write(filename, data) 
     101        reader_generic = Loader() 
     102        dataloader = reader_generic.load(self.isis_1_1) 
     103        reader_cansas = Reader() 
     104        cansasreader = reader_cansas.read(self.isis_1_1) 
     105        for i in range(len(dataloader)): 
     106            self._check_data(dataloader[i]) 
     107            self._check_data(cansasreader[i]) 
     108            reader_generic.save(filename, dataloader[i], None) 
    93109            reader2 = Reader() 
    94110            return_data = reader2.read(filename) 
    95111            data_new = return_data 
    96             self.data = return_data[0] 
    97             self.assertTrue(self.data.x.size == 138) 
    98             self.assertTrue(len(self.data.meta_data) == 2) 
    99             self.assertTrue(self.data.detector[0].distance_unit == "mm") 
    100             self.assertTrue(self.data.title == "TK49 c10_SANS") 
     112            written_data = return_data[0] 
     113            self._check_data(written_data) 
     114             
     115     
     116    def test_double_trans_spectra(self): 
     117        xmlreader = XMLreader(self.isis_1_1_doubletrans, self.schema_1_1) 
     118        self.assertTrue(xmlreader.validateXML()) 
     119        reader = Loader() 
     120        data = reader.load(self.isis_1_1_doubletrans) 
     121        for item in data: 
     122            self._check_data(item) 
     123     
    101124                     
    102125    def test_entry_name_recurse(self): 
Note: See TracChangeset for help on using the changeset viewer.