Changeset 574adc7 in sasview for src/sas/sascalc/pr/fit/Loader.py


Ignore:
Timestamp:
Sep 22, 2017 4:01:32 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
34d7b35
Parents:
9706d88
Message:

convert sascalc to python 2/3 syntax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/pr/fit/Loader.py

    ra1b8fee r574adc7  
    1818        self.dy = dy 
    1919        self.filename = None 
    20          
     20 
    2121    def set_filename(self, path=None): 
    2222        """ 
    23         Store path into a variable.If the user doesn't give  
     23        Store path into a variable.If the user doesn't give 
    2424        a path as a parameter a pop-up 
    2525        window appears to select the file. 
    26          
     26 
    2727        :param path: the path given by the user 
    28          
     28 
    2929        """ 
    3030        self.filename = path 
    31         
     31 
    3232    def get_filename(self): 
    3333        """ return the file's path""" 
    3434        return self.filename 
    35      
     35 
    3636    def set_values(self): 
    3737        """ Store the values loaded from file in local variables""" 
     
    4242            self.x = [] 
    4343            self.y = [] 
    44             self.dx = []  
     44            self.dx = [] 
    4545            self.dy = [] 
    4646            for line in lines: 
     
    5050                    y = float(toks[1]) 
    5151                    dy = float(toks[2]) 
    52                      
     52 
    5353                    self.x.append(x) 
    5454                    self.y.append(y) 
     
    5959            # Sanity check 
    6060            if not len(self.x) == len(self.dx): 
    61                 raise ValueError, "x and dx have different length" 
     61                raise ValueError("x and dx have different length") 
    6262            if not len(self.y) == len(self.dy): 
    63                 raise ValueError, "y and dy have different length" 
    64              
    65              
     63                raise ValueError("y and dy have different length") 
     64 
     65 
    6666    def get_values(self): 
    6767        """ Return x, y, dx, dy""" 
    6868        return self.x, self.y, self.dx, self.dy 
    69      
     69 
    7070    def load_data(self, data): 
    7171        """ Return plottable""" 
     
    7777        #Load its View class 
    7878        #plottable.reset_view() 
    79         
    80      
    81 if __name__ == "__main__":  
     79 
     80 
     81if __name__ == "__main__": 
    8282    load = Load() 
    8383    load.set_filename("testdata_line.txt") 
    84     print(load.get_filename())  
     84    print(load.get_filename()) 
    8585    load.set_values() 
    8686    print(load.get_values()) 
    87      
    88              
     87 
Note: See TracChangeset for help on using the changeset viewer.