Changeset acf8e4a5 in sasview


Ignore:
Timestamp:
Mar 31, 2015 11:52:01 AM (10 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, 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:
4342107f, c971c98
Parents:
6987c8a
Message:

reference BumpsFit? directly and remove fit engine selection layer

Files:
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • src/sas/perspectives/fitting/basepage.py

    r5ce7f17 racf8e4a5  
    9898        self.npts = None 
    9999        self.num_points = None 
    100         ## default fitengine type 
    101         self.engine_type = 'bumps' 
    102100        ## smear default 
    103101        self.current_smearer = None 
     
    947945        Store current state 
    948946        """ 
    949         self.state.engine_type = copy.deepcopy(self.engine_type) 
    950947        ## save model option 
    951948        if self.model != None: 
     
    10451042            self.state.disp_list = copy.deepcopy(self.disp_list) 
    10461043            self.state.model = self.model.clone() 
    1047         if hasattr(self, "engine_type"): 
    1048             self.state.engine_type = copy.deepcopy(self.engine_type) 
    10491044 
    10501045        self.state.enable2D = copy.deepcopy(self.enable2D) 
     
    12991294            # Backward compatibility (for older state files) 
    13001295            self.magnetic_on = False 
    1301         self.engine_type = state.engine_type 
    13021296 
    13031297        self.disp_cb_dict = state.disp_cb_dict 
     
    13551349            self.multifactorbox.SetSelection(state.multi_factor) 
    13561350 
    1357         #reset the fitting engine type 
    1358         self.engine_type = state.engine_type 
    1359         #draw the pnael according to the new model parameter 
     1351        #draw the panel according to the new model parameter 
    13601352        self._on_select_model(event=None) 
    13611353 
  • src/sas/perspectives/fitting/fitpage.py

    r682c432 racf8e4a5  
    183183            return True 
    184184        return False 
    185  
    186     def _on_engine_change(self, name): 
    187         """ 
    188         get the current name of the fit engine type 
    189          and update the panel accordingly 
    190         """ 
    191  
    192         self.engine_type = str(name) 
    193         self.state.engine_type = self.engine_type 
    194         if not self.is_mac: 
    195             if len(self.parameters) == 0: 
    196                 self.Layout() 
    197                 return 
    198             self.Layout() 
    199             self.Refresh() 
    200185 
    201186    def _fill_range_sizer(self): 
     
    28342819            self.SetupScrolling() 
    28352820            return 
    2836         ## the panel is drawn using the current value of the fit engine 
    2837         if self.engine_type == None and self._manager != None: 
    2838             self.engine_type = self._manager._return_engine_type() 
    28392821 
    28402822        box_description = wx.StaticBox(self, -1, str("Model Parameters")) 
  • src/sas/perspectives/fitting/fitpanel.py

    r2f4b430 racf8e4a5  
    6464        self.sim_page = None 
    6565        self.batch_page = None 
    66         self.fit_engine_type = "bumps" 
    6766        ## get the state of a page 
    6867        self.Bind(basepage.EVT_PAGE_INFO, self._onGetstate) 
  • src/sas/perspectives/fitting/fitting.py

    ra3f125f0 racf8e4a5  
    3232from sas.guiframe.plugin_base import PluginBase 
    3333from sas.guiframe.data_processor import BatchCell 
    34 from sas.fit.Fitting import Fit 
     34from sas.fit.BumpsFitting import BumpsFit as Fit 
    3535from sas.perspectives.fitting.console import ConsoleUpdate 
    3636from sas.perspectives.fitting.fitproblem import FitProblemDictionary 
     
    8484        ## dictionary of page closed and id 
    8585        self.closed_page_dict = {} 
    86         ## Fit engine 
    87         self._fit_engine = 'bumps' 
    88         self._gui_engine = None 
    8986        ## Relative error desired in the sum of squares (float) 
    9087        self.batch_reset_flag = True 
     
    751748    def stop_fit(self, uid): 
    752749        """ 
    753         Stop the fit engine 
     750        Stop the fit 
    754751        """ 
    755752        if uid in self.fit_thread_list.keys(): 
     
    877874        """ 
    878875        Get series of data, model, associates parameters and range and send then 
    879         to  series of fit engines. Fit data and model, display result to 
     876        to  series of fitters. Fit data and model, display result to 
    880877        corresponding panels. 
    881878        :param uid: id related to the panel currently calling this fit function. 
     
    896893        sim_fitter = None 
    897894        if fit_type == 'simultaneous': 
    898             #simulatanous fit only one engine need to be created 
    899             sim_fitter = Fit(self._fit_engine) 
     895            # for simultaneous fitting only one fitter is needed 
     896            sim_fitter = Fit() 
    900897            sim_fitter.fitter_id = self.sim_page.uid 
    901898            fitter_list.append(sim_fitter) 
     
    936933                    for fitproblem in  fitproblem_list: 
    937934                        if sim_fitter is None: 
    938                             fitter = Fit(self._fit_engine) 
     935                            fitter = Fit() 
    939936                            fitter.fitter_id = page_id 
    940937                            fitter_list.append(fitter) 
     
    965962        wx.PostEvent(self.parent, StatusEvent(status=msg, type="progress")) 
    966963 
    967         #Handler used for fit engine displayed message 
     964        #Handler used to display fit message 
    968965        handler = ConsoleUpdate(parent=self.parent, 
    969966                                manager=self, 
     
    11481145    def _add_problem_to_fit(self, fitproblem, pars, fitter, fit_id): 
    11491146        """ 
    1150         Create and set fit engine with series of data and model 
    1151         :param pars: list of fittable parameters 
    1152         :param fitter_list: list of fit engine 
    1153         :param value:  structure storing data mapped to their model, range etc. 
     1147        Create and set fitter with series of data and model 
    11541148        """ 
    11551149        data = fitproblem.get_fit_data() 
     
    12071201        """ 
    12081202        Display fit result in batch 
    1209         :param result: list of objects received fromt fit engines 
     1203        :param result: list of objects received from fitters 
    12101204        :param pars: list of  fitted parameters names 
    12111205        :param page_id: list of page ids which called fit function 
     
    13081302                            batch_inputs["error on %s" % str(param)].append(ERROR) 
    13091303                else: 
    1310                     # ToDo: Why sometimes res.pvec comes with numpy.float64? 
    1311                     # Need to fix it within ScipyEngine 
     1304                    # TODO: Why sometimes res.pvec comes with numpy.float64? 
     1305                    # probably from scipy lmfit 
    13121306                    if res.pvec.__class__ == numpy.float64: 
    13131307                        res.pvec = [res.pvec] 
     
    19211915                dy = numpy.ones(len(data_copy.y)) 
    19221916            else: 
    1923                 ## Set consitently w/AbstractFitengine: 
     1917                ## Set consistently w/AbstractFitengine: 
    19241918                # But this should be corrected later. 
    19251919                dy = deepcopy(data_copy.dy) 
  • src/sas/perspectives/fitting/pagestate.py

    rb1e609c racf8e4a5  
    4242                           ["name", "name", "string"], 
    4343                           ["data_name", "data_name", "string"]] 
    44 LIST_OF_STATE_ATTRIBUTES = [["engine_type", "engine_type", "string"], 
    45                             ["qmin", "qmin", "float"], 
     44LIST_OF_STATE_ATTRIBUTES = [["qmin", "qmin", "float"], 
    4645                            ["qmax", "qmax", "float"], 
    4746                            ["npts", "npts", "float"], 
     
    173172        self.reset = False 
    174173 
    175         #engine type 
    176         self.engine_type = None 
    177174        # flag to allow data2D plot 
    178175        self.enable2D = False 
     
    288285        obj.is_data = self.is_data 
    289286        obj.model_list_box = copy.deepcopy(self.model_list_box) 
    290         obj.engine_type = copy.deepcopy(self.engine_type) 
    291287 
    292288        obj.categorycombobox = self.categorycombobox 
  • src/sas/perspectives/fitting/simfitpage.py

    r2f4b430 racf8e4a5  
    152152 
    153153        ## making sure all parameters content a constraint 
    154         ## validity of the constraint expression is own by fit engine 
    155154        if not self.batch_on and self.show_constraint.GetValue(): 
    156155            if not self._set_constraint(): 
  • test/pr_inversion/test/test_output.txt

    r9f7fbd9 racf8e4a5  
    33#alpha=0.0007 
    44#chi2=836.797 
    5 #elapsed=0.000377893 
     5#elapsed=0.000389099 
    66#qmin=None 
    77#qmax=None 
  • test/sasfit/test/batch_fit.py

    refa5e44 racf8e4a5  
    33import unittest 
    44from sas.dataloader.loader import Loader 
    5 from sas.fit.Fitting import Fit 
     5from sas.fit.Fitting import BumpsFit as Fit 
    66from sas.models.CylinderModel import CylinderModel 
    77import sas.models.dispersion_models  
     
    4242        self.qmax = qmax 
    4343         
    44     def _reset_helper(self, path=None, engine="bumps", npts=NPTS): 
     44    def _reset_helper(self, path=None, npts=NPTS): 
    4545        """ 
    46         Set value to fitter engine and prepare inputs for map function 
     46        Set value to fitter and prepare inputs for map function 
    4747        """ 
    4848        for i in range(npts): 
    4949            data = Loader().load(path) 
    50             fitter = Fit(engine) 
     50            fitter = Fit() 
    5151            #create model 
    5252            model = CylinderModel() 
     
    7777            self.list_of_mapper.append(classMapper) 
    7878                    
    79     def reset_value(self, engine='bumps'): 
     79    def reset_value(self): 
    8080        """ 
    8181        Initialize inputs for the map function 
     
    8888 
    8989        path = "testdata_line3.txt" 
    90         self._reset_helper(path=path, engine=engine, npts=NPTS) 
     90        self._reset_helper(path=path, npts=NPTS) 
    9191        path = "testdata_line.txt" 
    92         self._reset_helper(path=path, engine=engine, npts=NPTS) 
     92        self._reset_helper(path=path, npts=NPTS) 
    9393        path = "SILIC010_noheader.DAT" 
    94         self._reset_helper(path=path, engine=engine, npts=NPTS) 
     94        self._reset_helper(path=path, npts=NPTS) 
    9595        path = "cyl_400_20.txt" 
    96         self._reset_helper(path=path, engine=engine, npts=NPTS) 
     96        self._reset_helper(path=path, npts=NPTS) 
    9797        path = "sphere_80.txt" 
    98         self._reset_helper(path=path, engine=engine, npts=NPTS) 
     98        self._reset_helper(path=path, npts=NPTS) 
    9999        path = "PolySpheres.txt" 
    100         self._reset_helper(path=path, engine=engine, npts=NPTS) 
     100        self._reset_helper(path=path, npts=NPTS) 
    101101        path = "latex_qdev.txt" 
    102         self._reset_helper(path=path, engine=engine, npts=NPTS) 
     102        self._reset_helper(path=path, npts=NPTS) 
    103103        path = "latex_qdev2.txt" 
    104         self._reset_helper(path=path, engine=engine, npts=NPTS) 
     104        self._reset_helper(path=path, npts=NPTS) 
    105105         
    106106       
  • test/sasfit/test/utest_fit_cylinder.py

    rc3caa49 racf8e4a5  
    77 
    88from sas.fit.AbstractFitEngine import Model 
    9 from sas.fit.Fitting import Fit 
     9from sas.fit.BumpsFitting import BumpsFit as Fit 
    1010from sas.dataloader.loader import Loader 
    1111 
     
    1515        """ initialize data""" 
    1616        self.data = Loader().load("cyl_400_20.txt") 
    17         # Create model that fitting engine understands 
     17        # Create model that fitter understands 
    1818        from sas.models.CylinderModel import CylinderModel 
    1919        self.model  = CylinderModel() 
     
    2727        self.pars1 =['length','radius','scale'] 
    2828         
    29     def _fit(self, name="bumps"): 
    30         """ return fit result """ 
    31         fitter = Fit(name) 
     29    def test_fit(self): 
     30        """Simple cylinder model fit""" 
     31        fitter = Fit() 
    3232        fitter.set_data(self.data,1) 
    3333        fitter.set_model(self.model,1,self.pars1) 
     
    4343        self.assertTrue( math.fabs(result1.pvec[2]-1.0)/3.0   < result1.stderr[2] ) 
    4444        self.assertTrue( result1.fitness < 1.0 ) 
    45  
    46  
    47     def test_bumps(self): 
    48         """ Simple cylinder model fit """ 
    49         self._fit("bumps") 
    5045 
    5146 
     
    8277    def test_constrained_bumps(self): 
    8378        """ Simultaneous cylinder model fit  """ 
    84         self._run_fit(Fit('bumps')) 
     79        self._run_fit(Fit()) 
    8580 
    8681    #@unittest.skip("") 
     
    9287 
    9388        for n, v, dv in zip(result1.param_list, result1.pvec, result1.stderr): 
    94             #print "%s M1.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 
    9589            if n == "length": 
    9690                self.assertTrue( math.fabs(v-400.0)/3.0 < dv ) 
     
    10094                self.assertTrue( math.fabs(v-1.0)/3.0 < dv ) 
    10195        for n, v, dv in zip(result2.param_list, result2.pvec, result2.stderr): 
    102             #print "%s M2.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 
    10396            if n=='radius': 
    10497                self.assertTrue( math.fabs(v-40.0)/3.0 < dv ) 
  • test/sasfit/test/utest_fit_line.py

    refa5e44 racf8e4a5  
    88from sas.fit.AbstractFitEngine import Model, FitHandler 
    99from sas.dataloader.loader import Loader 
    10 from sas.fit.Fitting import Fit 
     10from sas.fit.BumpsFitting import BumpsFit as Fit 
    1111from sas.models.LineModel import LineModel 
    1212from sas.models.Constant import Constant 
     
    1616 
    1717    def test_bad_pars(self): 
    18         fitter = Fit('bumps') 
     18        fitter = Fit() 
    1919 
    2020        data = Loader().load("testdata_line.txt") 
     
    3434            raise AssertionError("No error raised for fitting with wrong parameters name to fit") 
    3535 
    36     def fit_single(self, fitter_name, isdream=False): 
    37         fitter = Fit(fitter_name) 
     36    def fit_single(self, isdream=False): 
     37        fitter = Fit() 
    3838 
    3939        data = Loader().load("testdata_line.txt") 
     
    7474        #print "fitting",alg,opts 
    7575        #kprint "options",fitters.FIT_OPTIONS[alg].__dict__ 
    76         self.fit_single('bumps', isdream=(alg=='dream')) 
     76        self.fit_single(isdream=(alg=='dream')) 
    7777 
    7878    def test_bumps_de(self): 
     
    102102      
    103103        #Importing the Fit module 
    104         fitter = Fit('bumps') 
     104        fitter = Fit() 
    105105        # Receives the type of model for the fitting 
    106106        model11  = LineModel() 
     
    161161         
    162162        #Importing the Fit module 
    163         fitter = Fit('bumps') 
     163        fitter = Fit() 
    164164        fitter.set_data(data1,1) 
    165165        fitter.set_model(model1,1,pars1) 
     
    194194        #Importing the Fit module 
    195195 
    196         fitter = Fit('bumps') 
     196        fitter = Fit() 
    197197        fitter.set_data(data1,1,qmin=0, qmax=7) 
    198198        fitter.set_model(model,1,pars1) 
  • test/sasfit/test/utest_fit_smeared.py

    ra3f125f0 racf8e4a5  
    88import numpy 
    99from sas.fit.AbstractFitEngine import Model 
    10 from sas.fit.Fitting import Fit 
     10from sas.fit.BumpsFitting import BumpsFit as Fit 
    1111from sas.dataloader.loader import Loader 
    1212from sas.models.qsmearing import smear_selection 
     
    2424        #out.dy = out.y 
    2525         
    26         fitter = Fit('bumps') 
     26        fitter = Fit() 
    2727        fitter.set_data(out,1) 
    2828         
     
    6262        #fitters.FIT_OPTIONS[alg].options.update(opts) 
    6363        fitters.FIT_OPTIONS[alg].options.update(monitors=[]) 
    64         self._dispersion(fitter = Fit('bumps')) 
     64        self._dispersion(fitter = Fit()) 
    6565 
    6666    def _dispersion(self, fitter): 
     
    9494        #import time; T0 = time.time() 
    9595        result1, = fitter.fit() 
    96         #print "time",time.time()-T0,fitter._engine.__class__.__name__ 
    97          
     96 
    9897        self.assert_(result1) 
    9998        self.assertTrue(len(result1.pvec)>0) 
     
    137136 
    138137        # Fit 
    139         fitter = Fit('bumps') 
     138        fitter = Fit() 
    140139         
    141140        # Data: right now this is the only way to set the smearer object 
     
    143142        # data for a given fit. 
    144143        fitter.set_data(self.data_res,1) 
    145         fitter._engine.fit_arrange_dict[1].data_list[0].smearer = smear 
     144        fitter.fit_arrange_dict[1].data_list[0].smearer = smear 
    146145 
    147146        # Model: maybe there's a better way to do this. 
     
    169168        #self.assertEqual(smear.__class__.__name__, 'PySmearer') 
    170169 
    171         fitter = Fit('bumps') 
     170        fitter = Fit() 
    172171         
    173172        # Data: right now this is the only way to set the smearer object 
     
    175174        # data for a given fit. 
    176175        fitter.set_data(self.data_slit,1) 
    177         fitter._engine.fit_arrange_dict[1].data_list[0].smearer = smear 
    178         fitter._engine.fit_arrange_dict[1].data_list[0].qmax = 0.003 
     176        fitter.fit_arrange_dict[1].data_list[0].smearer = smear 
     177        fitter.fit_arrange_dict[1].data_list[0].qmax = 0.003 
    179178         
    180179        # Model 
  • test/sasfit/test/utest_multiplicative_model.py

    r769a422 racf8e4a5  
    88from sas.dataloader.data_info import Data1D  
    99from sas.fit.AbstractFitEngine import Model,FitData1D 
    10 from sas.fit.Fitting import Fit 
     10from sas.fit.BumpsFitting import BumpsFit as Fit 
    1111from sas.dataloader.loader import Loader 
    1212from sas.models.MultiplicationModel import MultiplicationModel 
     
    3838     
    3939        pars1 =['length','radius','scale_factor'] 
    40         fitter = Fit('bumps') 
     40        fitter = Fit() 
    4141        fitter.set_data(data,1) 
    4242        fitter.set_model(model,1,pars1) 
  • test/sasfit/test/utest_small_test.py

    refa5e44 racf8e4a5  
    44import unittest 
    55import math 
    6 from sas.fit.Fitting import Fit 
     6from sas.fit.BumpsFitting import BumpsFit as Fit 
    77from sas.dataloader.loader import Loader 
    88import bumps.fitters 
     
    1616        out= Loader().load("cyl_400_20.txt") 
    1717        
    18         fitter = Fit('bumps') 
     18        fitter = Fit() 
    1919        # Receives the type of model for the fitting 
    2020        from sas.models.CylinderModel import CylinderModel 
Note: See TracChangeset for help on using the changeset viewer.