Changeset f44dbc7 in sasview


Ignore:
Timestamp:
Aug 12, 2008 3:33:13 PM (16 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
985c88b
Parents:
ee5b04c
Message:

change made on set_model method receive a list instead of dict.
need to rewrite test

Location:
park_integration
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • park_integration/AbstractFitEngine.py

    ree5b04c rf44dbc7  
    3333            return xtemp, ytemp,dytemp 
    3434     
    35     def set_model(self,model,name,Uid,pars={}): 
     35    def set_model(self,model,name,Uid,pars=[]): 
    3636        """  
    3737       
     
    4949        print "AbstractFitEngine:  fitting parmater",pars 
    5050        
    51         if pars !={}: 
     51        if len(pars) >0: 
    5252            self.parameters=[] 
    53              
    5453            if model==None: 
    55                 raise ValueError, "Cannot set parameters for empty model" 
     54                raise ValueError, "AbstractFitEngine: Specify parameters to fit" 
    5655            else: 
    5756                model.name=name 
    58                 for key, value in pars.iteritems(): 
    59                     param = Parameter(model, key, value) 
     57                for param_name in pars: 
     58                    value=model.getParam(param_name) 
     59                    if value==None: 
     60                        raise ValueError ,"%s has not value set"%param_name 
     61                    param = Parameter(model,param_name,value) 
    6062                    self.parameters.append(param) 
    6163                    
  • park_integration/test/test_large_model.py

    rd53bc33 rf44dbc7  
    99class testFitModule(unittest.TestCase): 
    1010    """ test fitting """ 
    11     def testfit_1Data_1Model(self): 
    12         """ test fitting for one data and one model park vs scipy""" 
    13         #load data 
    14         from sans.fit.Loader import Load 
    15         load= Load() 
    16         load.set_filename("cyl_testdata.txt") 
    17         load.set_values() 
    18         data1 = Data1D(x=[], y=[],dx=None, dy=None) 
    19         load.load_data(data1) 
    20         
    21          
    22         #Importing the Fit module 
    23         from sans.fit.Fitting import Fit 
    24         fitter= Fit('scipy') 
    25          
    26         # Receives the type of model for the fitting 
    27         from sans.models.CylinderModel import CylinderModel 
    28         model1  = CylinderModel() 
    29        
    30          
    31         #Do the fit SCIPY 
    32         fitter.set_data(data1,1) 
    33         import math 
    34         pars1={'background':0,'contrast':3*math.pow(10, -6),\ 
    35                 'cyl_phi':1,'cyl_theta':1,'length':400,'radius':20,'scale':1} 
    36         fitter.set_model(model1,"M1",1,pars1) 
    37         
    38          
    39         chisqr1, out1, cov1=fitter.fit() 
    40         print "scipy1",chisqr1, out1, cov1 
    41         pars2={'background':1.0,'contrast':400,\ 
    42                 'cyl_phi':20,'cyl_theta':0.0,'length':1.0,\ 
    43                 'radius':3*math.pow(10, -6),'scale':1.0} 
    44         fitter.set_model(model1,"M1",1,pars2) 
    45         chisqr2, out2, cov2=fitter.fit() 
    46         print "scipy2",chisqr2, out2, cov2 
    47          
    48         pars3={'background':5.85693826,'contrast': 5.86071451,\ 
    49                 'cyl_phi':1.04547760*math.pow(10,-5),'cyl_theta':1.0,'length':0.0,\ 
    50                 'radius':1.39397013*math.pow(10, 3),'scale':20} 
    51         fitter.set_model(model1,"M1",1,pars3) 
    52         chisqr3, out3, cov3=fitter.fit() 
    53         print "scipy3",chisqr3, out3, cov3 
    54         self.assert_(chisqr1) 
    55          
    56         
     11     
    5712       
    5813    def testfit_11Data_1Model(self): 
Note: See TracChangeset for help on using the changeset viewer.