Changeset 61f329f0 in sasview for src/sas/sascalc/dataloader


Ignore:
Timestamp:
Oct 25, 2017 5:46:56 AM (7 years ago)
Author:
krzywon
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
fe15198
Parents:
5582b078
Message:

Reset file reader class data state each time a new data file is loaded.

Location:
src/sas/sascalc/dataloader
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/file_reader_base_class.py

    r9e6aeaf r61f329f0  
    5454        :param filepath: The full or relative path to a file to be loaded 
    5555        """ 
     56        self.reset_state() 
    5657        if os.path.isfile(filepath): 
    5758            basename, extension = os.path.splitext(os.path.basename(filepath)) 
     
    8687        # Return a list of parsed entries that data_loader can manage 
    8788        return self.output 
     89 
     90    def reset_state(self): 
     91        """ 
     92        Resets the class state to a base case when loading a new data file so previous 
     93        data files do not appear a second time 
     94        """ 
     95        self.current_datainfo = None 
     96        self.current_dataset = None 
     97        self.output = [] 
    8898 
    8999    def nextline(self): 
  • src/sas/sascalc/dataloader/readers/cansas_reader.py

    r2b538cd r61f329f0  
    6868        data files do not appear a second time 
    6969        """ 
    70         self.current_datainfo = None 
    71         self.current_dataset = None 
    72         self.current_data1d = None 
     70        super(Reader, self).reset_state() 
    7371        self.data = [] 
    7472        self.process = Process() 
     
    7977        self.names = [] 
    8078        self.cansas_defaults = {} 
    81         self.output = [] 
    8279        self.ns_list = None 
    8380        self.logging = [] 
  • src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py

    r2b538cd r61f329f0  
    6565        """ 
    6666        # Reinitialize when loading a new data file to reset all class variables 
    67         self.reset_class_variables() 
     67        self.reset_state() 
    6868 
    6969        filename = self.f_open.name 
     
    101101                            raise FileContentsException("Fewer than 5 data points found.") 
    102102 
    103     def reset_class_variables(self): 
     103    def reset_state(self): 
    104104        """ 
    105105        Create the reader object and define initial states for class variables 
    106106        """ 
    107         self.current_datainfo = None 
    108         self.current_dataset = None 
     107        super(Reader, self).reset_state() 
    109108        self.data1d = [] 
    110109        self.data2d = [] 
     
    112111        self.errors = set() 
    113112        self.logging = [] 
    114         self.output = [] 
    115113        self.parent_class = u'' 
    116114        self.detector = Detector() 
Note: See TracChangeset for help on using the changeset viewer.