Changeset 316e231 in sasview


Ignore:
Timestamp:
May 3, 2012 11:23:15 AM (12 years ago)
Author:
Jae Cho <jhjcho@…>
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:
56acb5d
Parents:
74d7b59
Message:

set all the custom model names same as its filename

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • calculatorview/src/sans/perspectives/calculator/model_editor.py

    r41a8cb3 r316e231  
    324324            elif line.count("self.description = '%s'"): 
    325325                out_f.write(line % description + "\n") 
    326             elif line.count("self.name = '%s'"): 
    327                 out_f.write(line % name + "\n") 
     326            #elif line.count("self.name = '%s'"): 
     327            #    out_f.write(line % name + "\n") 
    328328            else: 
    329329                out_f.write(line + "\n") 
     
    690690                if has_scipy: 
    691691                    out_f.write("import scipy" + "\n") 
    692             elif line.count("name = "): 
    693                 out_f.write(line % self.name + "\n") 
     692            #elif line.count("name = "): 
     693            #    out_f.write(line % self.name + "\n") 
    694694            elif line: 
    695695                out_f.write(line + "\n") 
     
    777777from sans.models.pluginmodel import Model1DPlugin 
    778778from math import * 
     779import os 
     780import sys 
    779781import numpy 
    780782#import scipy? 
    781783class Model(Model1DPlugin): 
    782     name = "%s"                              
     784    name = ""                              
    783785    def __init__(self): 
    784         Model1DPlugin.__init__(self, name=self.name)                                                      
     786        Model1DPlugin.__init__(self, name=self.name)   
     787        #set name same as file name  
     788        self.name = self.get_fname()                                                    
    785789        #self.params here 
    786790        self.description = "%s" 
     
    827831""" 
    828832TEST_TEMPLATE = """ 
     833    def get_fname(self): 
     834        path = sys._getframe().f_code.co_filename 
     835        basename  = os.path.basename(path) 
     836        name, _ = os.path.splitext(basename) 
     837        return name 
    829838###################################################################### 
    830839## THIS IS FOR TEST. DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
     
    854863#P2_model:  
    855864from sans.models.%s import %s as P2 
     865import os 
     866import sys 
    856867 
    857868class Model(Model1DPlugin): 
     
    863874        ## Setting  model name model description 
    864875        self.description = '%s' 
    865         self.name = '%s' 
     876        self.name = self.get_fname() 
    866877        if self.name.rstrip().lstrip() == '': 
    867878            self.name = self._get_name(p_model1.name, p_model2.name) 
     
    11181129( p_model1.name, p_model2.name ) 
    11191130        self.description += description 
    1120          
     1131           
     1132    def get_fname(self): 
     1133        path = sys._getframe().f_code.co_filename 
     1134        basename  = os.path.basename(path) 
     1135        name, _ = os.path.splitext(basename) 
     1136        return name      
     1137            
    11211138if __name__ == "__main__":  
    11221139    m1= Model()  
  • fittingview/src/sans/perspectives/fitting/plugin_models/polynominal5.py

    r19e614a r316e231  
    2020import math                    ##DO NOT CHANGE THIS LINE!!! 
    2121import numpy                   ##DO NOT CHANGE THIS LINE!!! 
    22  
     22import os 
     23import sys 
    2324## <-----  SIGN DEFINES WHERE YOU CAN MODIFY THE CODE 
    2425 
     
    3031    ##EXAMPLE: Class that evaluates a polynomial model.  
    3132    """ 
    32     ## YOU CAN MODIFY THE LINE BELLOW. CHANGE ONLY WORDS BETWEEN " "  
    33     ## TO RENAME YOUR MODEL: THIS NAME IS WHAT YOU SEE ON GUI. 
    34     name = "polynomial5"        ## <----- FILE NAME (NAME OF THE MODEL)    
     33    name = ""   
    3534                                 
    3635    def __init__(self):      ##DO NOT CHANGE THIS LINE!!! 
     
    4847        self.params['E'] = 0.0       ## <-----                   
    4948        self.params['F'] = 0.0       ## <-----    
     49        # Set the name same as the file name 
     50        self.name = self.get_fname()     ##DO NOT CHANGE THIS LINE!!! 
    5051        ## YOU CAN MODIFY THE LINE BELLOW.MODIFY WORDS BETWEEN """   """  ONLY!!!! 
    5152        self.description = """ 
     
    8889 
    8990        return result       ## MODIFY ONLY RESULT. DON'T DELETE RETURN!!!! 
    90  
     91     
     92    ## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
     93    def get_fname(self): 
     94        """ 
     95        Get the model name same as the file name 
     96        """ 
     97        path = sys._getframe().f_code.co_filename 
     98        basename  = os.path.basename(path) 
     99        name, _ = os.path.splitext(basename) 
     100        return name 
     101             
    91102############################################################################### 
    92103## THIS IS FOR TEST. DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
  • fittingview/src/sans/perspectives/fitting/plugin_models/sph_bessel_jn.py

    r19e614a r316e231  
    1919import numpy                 ##DO NOT CHANGE THIS LINE!!! 
    2020import scipy.special            ##CHANGE THIS LINE WITH CAUTION!!! 
    21  
     21import os 
     22import sys 
    2223##PLEASE READ COMMENTS CAREFULLY !!! COMMENT ARE IN CAPITAL LETTERS AND AFTER ## 
    2324## THESE COMMENTS ARE THERE TO GUIDE YOU. YOU CAN REMOVE THEM ONLY WHEN YOU ARE 
     
    3435    ##EXAMPLE: Class that evaluates a polynomial model.  
    3536    """ 
    36     ## YOU CAN MODIFY THE LINE BELLOW. CHANGE ONLY WORDS BETWEEN " "  
    37     ## TO RENAME YOUR MODEL 
    38     name = "sph_bessel_jn" ## <----- FILE NAME (NAME OF THE MODEL)    
     37    name = ""  
    3938                                 
    4039    def __init__(self):      ##DO NOT CHANGE THIS LINE!!! 
     
    4746        ## DELETE MODIFIABLE LINE HERE WILL REDUCE THE NUMBER OF PARAMETERS 
    4847        self.params = {}                ##DO NOT CHANGE THIS LINE!!! 
    49          
     48        # Set the name same as the file name 
     49        self.name = self.get_fname()     ##DO NOT CHANGE THIS LINE!!! 
    5050        ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER  
    5151        ## YOU CAN ALSO DELETE THIS LINE 
     
    112112 
    113113        return result ## MODIFY ONLY RESULT. DON'T DELETE RETURN!!!! 
    114  
     114     
     115    ## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!       
     116    def get_fname(self): 
     117        """ 
     118        Get the model name same as the file name 
     119        """ 
     120        path = sys._getframe().f_code.co_filename 
     121        basename  = os.path.basename(path) 
     122        name, _ = os.path.splitext(basename) 
     123        return name 
     124             
    115125###############################################################################    
    116126## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
  • fittingview/src/sans/perspectives/fitting/plugin_models/sum_Ap1_1_Ap2.py

    r19e614a r316e231  
    22import copy 
    33from sans.models.pluginmodel import Model1DPlugin 
    4  
     4import os 
     5import sys 
    56""" 
    67## ***************************************************************************** 
     
    4344    Note: P(Q) refers to 'form factor' model. 
    4445    """ 
    45     name = "sum_Ap1_1_Ap2" ## <----- FILE NAME (NAME OF THE MODEL)  
     46    name = ""  
    4647    def __init__(self): 
    4748        Model1DPlugin.__init__(self, name=self.name) 
     
    5556        self.description = "" 
    5657        self.fill_description(p_model1, p_model2) 
    57  
     58        # Set the name same as the file name 
     59        self.name = self.get_fname()     ##DO NOT CHANGE THIS LINE!!! 
    5860        ## Define parameters 
    5961        self.params = {} 
     
    391393                                        ( p_model1.name, p_model2.name ) 
    392394        self.description += description 
    393  
     395     
     396    ## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
     397    def get_fname(self): 
     398        """ 
     399        Get the model name same as the file name 
     400        """ 
     401        path = sys._getframe().f_code.co_filename 
     402        basename  = os.path.basename(path) 
     403        name, _ = os.path.splitext(basename) 
     404        return name 
     405             
    394406### FOR TEST                 
    395407if __name__ == "__main__":  
  • fittingview/src/sans/perspectives/fitting/plugin_models/sum_p1_p2.py

    r19e614a r316e231  
    22import copy 
    33from sans.models.pluginmodel import Model1DPlugin 
    4  
     4import os 
     5import sys 
    56""" 
    67## ***************************************************************************** 
     
    4849    Note: P(Q) refers to 'form factor' model. 
    4950    """ 
    50     name = "sum_p1_p2" ## <----- FILE NAME (NAME OF THE MODEL)  
     51    name = ""  
    5152    def __init__(self): 
    5253        Model1DPlugin.__init__(self, name=self.name) 
     
    6364        self.description += p_model2.name+"\n" 
    6465        self.fill_description(p_model1, p_model2) 
    65  
     66        # Set the name same as the file name 
     67        self.name = self.get_fname()     ##DO NOT CHANGE THIS LINE!!! 
    6668        ## Define parameters 
    6769        self.params = {} 
     
    399401                                        ( p_model1.name, p_model2.name ) 
    400402        self.description += description 
    401          
     403     
     404    ## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
     405    def get_fname(self): 
     406        """ 
     407        Get the model name same as the file name 
     408        """ 
     409        path = sys._getframe().f_code.co_filename 
     410        basename  = os.path.basename(path) 
     411        name, _ = os.path.splitext(basename) 
     412        return name 
     413             
    402414if __name__ == "__main__":  
    403415    m1= Model()  
  • fittingview/src/sans/perspectives/fitting/plugin_models/testmodel.py

    r19e614a r316e231  
    1818import math                  ##DO NOT CHANGE THIS LINE!!! 
    1919import numpy               ##DO NOT CHANGE THIS LINE!!! 
    20  
     20import os 
     21import sys 
    2122##PLEASE READ COMMENTS CAREFULLY !!! COMMENT ARE IN CAPITAL LETTERS AND AFTER ## 
    2223## THESE COMMENTS ARE THERE TO GUIDE YOU. YOU CAN REMOVE THEM ONLY WHEN YOU ARE 
     
    3334    ##EXAMPLE:Class that evaluates a cos(x) model.  
    3435    """ 
    35      
    36     ## YOU CAN MODIFY THE LINE BELLOW. CHANGE ONLY WORDS BETWEEN " "  
    37     ## TO RENAME YOUR MODEL 
    38     name = "testmodel"      ## <----- FILE NAME (NAME OF THE MODEL)    
     36    name = ""      
    3937     
    4038    def __init__(self): 
     
    4745        ## DELETE MODIFIABLE LINE HERE WILL REDUCE THE NUMBER OF PARAMETERS 
    4846        self.params = {}                        ##DO NOT CHANGE THIS LINE!!! 
     47        # Set the name same as the file name 
     48        self.name = self.get_fname()     ##DO NOT CHANGE THIS LINE!!! 
    4949        ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER  
    5050        ## YOU CAN ALSO DELETE THIS LINE 
     
    8686        return self.params['A']+self.params['B']*math.cos(2.0*x)+self.params['C']*math.sin(2.0*x) 
    8787     
     88    ## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!    
     89    def get_fname(self): 
     90        """ 
     91        Get the model name same as the file name 
     92        """ 
     93        path = sys._getframe().f_code.co_filename 
     94        basename  = os.path.basename(path) 
     95        name, _ = os.path.splitext(basename) 
     96        return name 
     97     
    8898## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
    8999if __name__ == "__main__":  
  • fittingview/src/sans/perspectives/fitting/plugin_models/testmodel_2.py

    r19e614a r316e231  
    1818import math                     ##DO NOT CHANGE THIS LINE!!! 
    1919import numpy                    ##DO NOT CHANGE THIS LINE!!! 
    20  
     20import os 
     21import sys 
    2122##PLEASE READ COMMENTS CAREFULLY !!! COMMENT ARE IN CAPITAL LETTERS AND AFTER ## 
    2223## THESE COMMENTS ARE THERE TO GUIDE YOU. YOU CAN REMOVE THEM ONLY WHEN YOU ARE 
     
    3334    ##EXAMPLE: Class that evaluates a polynomial model.  
    3435    """ 
    35     ## YOU CAN MODIFY THE LINE BELLOW. CHANGE ONLY WORDS BETWEEN " "  
    36     ## TO RENAME YOUR MODEL 
    37     name = "testmodel_2" ## <----- FILE NAME (NAME OF THE MODEL)   
     36    name = ""  
    3837                                 
    3938    def __init__(self):      ##DO NOT CHANGE THIS LINE!!! 
     
    4645        ## DELETE MODIFIABLE LINE HERE WILL REDUCE THE NUMBER OF PARAMETERS 
    4746        self.params = {}                ##DO NOT CHANGE THIS LINE!!! 
    48          
     47        # Set the name same as the file name 
     48        self.name = self.get_fname()     ##DO NOT CHANGE THIS LINE!!! 
    4949        ## YOU CAN MODIFY THE LINE BELLOW.CHANGE WORD BETWEEN ' ' AND NUMBER  
    5050        ## YOU CAN ALSO DELETE THIS LINE 
     
    148148 
    149149        return result ## MODIFY ONLY RESULT. DON'T DELETE RETURN!!!! 
    150      
     150 
     151    ## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!    
     152    def get_fname(self): 
     153        """ 
     154        Get the model name same as the file name 
     155        """ 
     156        path = sys._getframe().f_code.co_filename 
     157        basename  = os.path.basename(path) 
     158        name, _ = os.path.splitext(basename) 
     159        return name 
     160                 
    151161## DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!        
    152162if __name__ == "__main__":  
Note: See TracChangeset for help on using the changeset viewer.