Changeset 386ffe1 in sasview


Ignore:
Timestamp:
Feb 20, 2015 3:02:38 AM (9 years ago)
Author:
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:
cda1cf8
Parents:
018582f
Message:

remove scipy levenburg marquardt and park from ui

Files:
1 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • docs/pre-sphinx-docs/simultaneous_fit_help_v0.html

    r54b9ad2 r386ffe1  
    77        It requires one or more FitPages with a data and a model set for the fitting,  
    88        and performs multiple fittings given by the FitPage(s). 
    9         The Complex (ParkMC) FitEngine will be used automatically. 
    109</p> 
    1110<ul> 
  • src/sas/fit/AbstractFitEngine.py

    rfd5ac0d r386ffe1  
    1010_SMALLVALUE = 1.0e-10 
    1111 
    12 # Note: duplicated from park 
    1312class FitHandler(object): 
    1413    """ 
     
    6968    def __init__(self, sas_model, sas_data=None, **kw): 
    7069        """ 
    71         :param sas_model: the sas model to wrap using park interface 
     70        :param sas_model: the sas model to wrap for fitting 
    7271 
    7372        """ 
     
    10099    def eval(self, x): 
    101100        """ 
    102             Override eval method of park model. 
     101            Override eval method of model. 
    103102 
    104103            :param x: the x value used to compute a function 
     
    394393    def __init__(self): 
    395394        """ 
    396         Base class for scipy and park fit engine 
     395        Base class for the fit engine 
    397396        """ 
    398397        #Dictionnary of fitArrange element (fit problems) 
  • src/sas/fit/BumpsFitting.py

    rfd5ac0d r386ffe1  
    1010from bumps.mapper import SerialMapper, MPMapper 
    1111from bumps import parameter 
     12 
     13# TODO: remove globals from interface to bumps options! 
     14# Default bumps to use the levenberg-marquardt optimizer 
    1215from bumps.fitproblem import FitProblem 
     16fitters.FIT_DEFAULT = 'lm' 
    1317 
    1418from sas.fit.AbstractFitEngine import FitEngine 
  • src/sas/fit/Fitting.py

    r79492222 r386ffe1  
    11""" 
    2 Class Fit contains ScipyFit and ParkFit methods declaration 
    3 allows to create instance of type ScipyFit or ParkFit to perform either 
    4 a park fit or a scipy fit. 
     2Class Fit contains fitting engine methods declaration 
    53""" 
    64 
    7 #from scipy import optimize 
    8 from sas.fit.ScipyFitting import ScipyFit 
    9 from sas.fit.ParkFitting import ParkFit 
    105from sas.fit.BumpsFitting import BumpsFit 
    116 
    127ENGINES={ 
    13     'scipy': ScipyFit, 
    14     'park': ParkFit, 
    158    'bumps': BumpsFit, 
    169} 
     
    2316        from sas.fit.Fitting import Fit 
    2417        fitter= Fit() 
    25         fitter.fit_engine('scipy') or fitter.fit_engine('park') 
     18        fitter.fit_engine('bumps') 
    2619        engine = fitter.returnEngine() 
    2720        engine.set_data(data,id) 
     
    3225         
    3326    """   
    34     def __init__(self, engine='scipy', *args, **kw): 
     27    def __init__(self, engine='bumps', *args, **kw): 
    3528        """ 
    3629        """ 
    37         #self._engine will contain an instance of ScipyFit or ParkFit 
    3830        self._engine = None 
    3931        self.fitter_id = None 
     
    6153        :param word: the keyword to select the fit type  
    6254         
    63         :raise: if the user does not enter 'scipy' or 'park', 
    64              a valueError is raised  
    65               
     55        :raise: KeyError if the user does not enter an available engine 
     56 
    6657        """ 
    6758        try: 
    6859            self._engine = ENGINES[word](*args, **kw) 
    6960        except KeyError, exc: 
    70             raise KeyError("fit engine should be one of scipy, park or bumps") 
     61            raise KeyError("fit engine should be bumps") 
     62            #raise KeyError("fit engine should be one of "+", ".join(sorted(ENGINES.keys()))) 
    7163 
    7264    def fit(self, msg_q=None, q=None, handler=None,  
     
    7567                        reset_flag=False): 
    7668        """Perform the fit """ 
    77         return self._engine.fit(msg_q=msg_q,  
     69        return self._engine.fit(msg_q=msg_q, 
    7870                                q=q, handler=handler, curr_thread=curr_thread, 
    7971                                ftol=ftol, reset_flag=reset_flag) 
  • src/sas/fit/ParkFitting.py

    rfd5ac0d r386ffe1  
    77to perform a simple fit with park optimizer. 
    88""" 
     9 
     10_ = ''' 
    911#import time 
    1012import numpy 
     
    615617            return q 
    616618        return result_list 
    617         
     619 
     620''' 
  • src/sas/fit/ScipyFitting.py

    ra10364b r386ffe1  
    44simple fit with scipy optimizer. 
    55""" 
     6_ = ''' 
    67import sys 
    78import copy 
     
    265266    if it is out of range. 
    266267 
    267     : model: park model object 
     268    : model: model object 
    268269    """ 
    269270    # loop through parameterset 
     
    306307#    return call_result 
    307308 
    308        
     309 
     310''' 
  • src/sas/perspectives/fitting/fit_thread.py

    r79492222 r386ffe1  
    2828                 yieldtime  = 0.03, 
    2929                 worktime   = 0.03, 
    30                  ftol       = None, 
    3130                 reset_flag = False): 
    3231        CalcThread.__init__(self, 
     
    4443        self.updatefn = updatefn 
    4544        #Relative error desired in the sum of squares. 
    46         self.ftol = ftol 
    4745        self.reset_flag = reset_flag 
    4846    
     
    6765            list_handler = [] 
    6866            list_curr_thread = []  
    69             list_ftol = [] 
    7067            list_reset_flag = [] 
    7168            list_map_get_attr = [] 
     
    7673                list_q.append(None) 
    7774                list_curr_thread.append(self) 
    78                 list_ftol.append(self.ftol) 
    7975                list_reset_flag.append(self.reset_flag) 
    8076                list_fit_function.append('fit') 
     
    8278            #from multiprocessing import Pool 
    8379            inputs = zip(list_map_get_attr, self.fitter, list_fit_function, 
    84                          list_q, list_q, list_handler,list_curr_thread,list_ftol, 
     80                         list_q, list_q, list_handler,list_curr_thread, 
    8581                         list_reset_flag) 
    8682            result =  map(map_apply, inputs) 
  • src/sas/perspectives/fitting/fitpage.py

    r22ae2f7 r386ffe1  
    10031003            return 
    10041004 
    1005         if (len(self._manager.fit_thread_list) > 0 
    1006                 and self._manager._fit_engine not in ("park","bumps") 
    1007                 and self._manager.sim_page != None 
    1008                 and self._manager.sim_page.uid == self.uid): 
    1009             msg = "The FitEnging will be set to 'ParkMC'\n" 
    1010             msg += " to fit with more than one data set..." 
    1011             wx.MessageBox(msg, 'Info') 
    1012              
    10131005        if self.data is None: 
    10141006            msg = "Please get Data first..." 
     
    20342026        return numbers of data points within qrange 
    20352027         
    2036         :Note: This is for Park where chi2 is not normalized by Npts of fit 
     2028        :Note: This is to normalize chisq by Npts of fit 
    20372029         
    20382030        """ 
     
    32303222        # Figuring out key combo: Cmd for copy, Alt for paste 
    32313223        if event.AltDown() and event.ShiftDown(): 
    3232             self._manager.show_ftol_dialog() 
    32333224            flag = True 
    32343225        elif event.AltDown() or event.ShiftDown(): 
     
    32403231        # messages depending on the flag 
    32413232        if not flag: 
    3242             msg = " Could not open ftol dialog;" 
    3243             msg += " Check if the Scipy fit engine is selected in the menubar." 
    32443233            infor = 'warning' 
    32453234            # inform msg to wx 
  • src/sas/perspectives/fitting/fitpanel.py

    rfa09d62 r386ffe1  
    110110        return doc 
    111111     
    112     def _on_engine_change(self, name='scipy'): 
    113         """ 
    114         """ 
    115         for panel in self.opened_pages.values(): 
    116             self.set_engine_helper(panel=panel, name=name) 
    117              
    118     def set_engine_helper(self, panel, name='scipy'): 
    119         """ 
    120         """ 
    121         self.fit_engine_type = name 
    122         if panel not in[self.batch_page, self.sim_page]: 
    123             panel._on_engine_change(name=self.fit_engine_type) 
    124                  
    125112    def update_model_list(self): 
    126113        """ 
     
    393380        self.AddPage(panel, caption, select=True) 
    394381        self.opened_pages[panel.uid] = panel 
    395         self.set_engine_helper(panel=panel) 
    396382        self._manager.create_fit_problem(panel.uid) 
    397383        self._manager.page_finder[panel.uid].add_data(panel.get_data()) 
  • src/sas/perspectives/fitting/fitting.py

    rfd5ac0d r386ffe1  
    4545from sas.guiframe.gui_manager import MDIFrame 
    4646 
    47 # TODO: remove globals from interface to bumps options! 
    48 # Default bumps to use the levenberg-marquardt optimizer 
    49 import bumps.fitters 
    50 bumps.fitters.FIT_DEFAULT = 'lm' 
    51  
    5247MAX_NBR_DATA = 4 
    53 SAS_F_TOL = 5e-05 
    5448 
    5549(PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() 
     
    9387        self._fit_engine = 'bumps' 
    9488        self._gui_engine = None 
    95         ## Relative error desired in the sum of squares (float); scipy only 
    96         self.ftol = SAS_F_TOL 
     89        ## Relative error desired in the sum of squares (float) 
    9790        self.batch_reset_flag = True 
    9891        #List of selected data 
     
    112105        self.state_reader = None 
    113106        self._extensions = '.fitv' 
    114         self.scipy_id = wx.NewId() 
    115         self.park_id = wx.NewId() 
    116         self.bumps_id = wx.NewId() 
    117107        self.menu1 = None 
    118108        self.new_model_frame = None 
     
    191181        self.batch_menu.Enable(False) 
    192182        self.menu1.AppendSeparator() 
    193         #Set park engine 
    194         scipy_help = "Scipy Engine: Perform Simple fit. More in Help window...." 
    195         self.menu1.AppendCheckItem(self.scipy_id, "Simple FitEngine [LeastSq]", 
    196                                    scipy_help) 
    197         wx.EVT_MENU(owner, self.scipy_id, self._onset_engine_scipy) 
    198          
    199         park_help = "Park Engine: Perform Complex fit. More in Help window...." 
    200         self.menu1.AppendCheckItem(self.park_id, "Complex FitEngine [ParkMC]", 
    201                                    park_help) 
    202         wx.EVT_MENU(owner, self.park_id, self._onset_engine_park) 
    203          
    204         bumps_help = "Bumps: fitting and uncertainty analysis. More in Help window...." 
    205         self.menu1.AppendCheckItem(self.bumps_id, "Bumps fit", 
    206                                    bumps_help) 
    207         wx.EVT_MENU(owner, self.bumps_id, self._onset_engine_bumps) 
    208          
    209         self.menu1.FindItemById(self.scipy_id).Check(self._fit_engine=="scipy") 
    210         self.menu1.FindItemById(self.park_id).Check(self._fit_engine=="park") 
    211         self.menu1.FindItemById(self.bumps_id).Check(self._fit_engine=="bumps") 
     183 
    212184        self.menu1.AppendSeparator() 
    213         self.id_tol = wx.NewId() 
    214         ftol_help = "Change the current FTolerance (=%s) " % str(self.ftol) 
    215         ftol_help += "of Simple FitEngine..." 
    216         self.menu1.Append(self.id_tol, "Change FTolerance", 
    217                                    ftol_help) 
    218         wx.EVT_MENU(owner, self.id_tol, self.show_ftol_dialog) 
    219  
    220185        self.id_bumps_options = wx.NewId() 
    221         bopts_help = "Bumps fitting options" 
    222         self.menu1.Append(self.id_bumps_options, 'Bumps &Options', bopts_help) 
     186        bopts_help = "Fitting options" 
     187        self.menu1.Append(self.id_bumps_options, 'Fit &Options', bopts_help) 
    223188        wx.EVT_MENU(owner, self.id_bumps_options, self.on_bumps_options) 
    224189        self.bumps_options_menu = self.menu1.FindItemById(self.id_bumps_options) 
     
    776741        :param value: can be a string in this case. 
    777742        :param names: the paramter name 
    778           
    779         :note: expecting park used for fit. 
    780           
    781743        """ 
    782744        sim_page_id = self.sim_page.uid 
     
    808770            return model_name, param_name 
    809771    
    810     def set_ftol(self, ftol=None): 
    811         """ 
    812         Set ftol: Relative error desired in the sum of chi squares. 
    813         """ 
    814         # check if it is flaot 
    815         try: 
    816             f_tol = float(ftol) 
    817         except: 
    818             # default 
    819             f_tol = SAS_F_TOL 
    820              
    821         self.ftol = f_tol 
    822         # update ftol menu help strings 
    823         ftol_help = "Change the current FTolerance (=%s) " % str(self.ftol) 
    824         ftol_help += "of Simple FitEngine..." 
    825         if self.menu1 != None: 
    826             self.menu1.SetHelpString(self.id_tol, ftol_help) 
    827          
    828     def show_ftol_dialog(self, event=None): 
    829         """ 
    830         Dialog to select ftol for Scipy 
    831         """ 
    832         from ftol_dialog import ChangeFtol 
    833         dialog = ChangeFtol(self.parent, self) 
    834         result = dialog.ShowModal() 
    835         if result == wx.ID_OK: 
    836             value = dialog.get_ftol() 
    837             if value is not None: 
    838                 self.set_ftol(value) 
    839                 msg = "The ftol (LeastSq) is set to %s." % value 
    840             else: 
    841                 msg = "Error in the selection... No change in ftol." 
    842             # post event for info 
    843             wx.PostEvent(self.parent, 
    844                          StatusEvent(status=msg, info='warning')) 
    845         dialog.Destroy() 
    846  
    847772    def on_bumps_options(self, event=None): 
    848773        from bumps.gui.fit_dialog import OpenFitOptions 
     
    983908        if uid is None: raise RuntimeError("no page to fit") # Should never happen 
    984909 
    985         # Remember the user selected fit engine before the fit.  Simultaneous 
    986         # fitting may change the selected engine, so it needs to be restored 
    987         # when the fit is complete. 
    988         self._gui_engine = self._fit_engine 
    989  
    990910        sim_page_uid = getattr(self.sim_page, 'uid', None) 
    991911        batch_page_uid = getattr(self.batch_page, 'uid', None) 
     
    997917        else: 
    998918            fit_type = 'single' 
    999  
    1000         # if constrained fit, don't use scipy leastsq directly 
    1001         if fit_type == 'simultaneous': 
    1002             if self._fit_engine not in ("park","bumps"): 
    1003                 self._on_change_engine(engine='bumps') 
    1004  
    1005919 
    1006920        fitter_list = [] 
     
    1075989        wx.PostEvent(self.parent, StatusEvent(status=msg, type="progress")) 
    1076990         
    1077         #Handler used for park engine displayed message 
     991        #Handler used for fit engine displayed message 
    1078992        handler = ConsoleUpdate(parent=self.parent, 
    1079993                                manager=self, 
     
    10981012                                 page_id=list_page_id, 
    10991013                                 completefn=self._batch_fit_complete, 
    1100                                  ftol=self.ftol, 
    11011014                                 reset_flag=self.batch_reset_flag) 
    11021015        else: 
     
    11081021                                    page_id=list_page_id, 
    11091022                                    updatefn=handler.update_fit, 
    1110                                     completefn=self._fit_completed, 
    1111                                     ftol=self.ftol) 
     1023                                    completefn=self._fit_completed) 
    11121024        #self.fit_thread_list[current_page_id] = calc_fit 
    11131025        self.fit_thread_list[uid] = calc_fit 
     
    15681480                                                      type="stop")) 
    15691481        wx.PostEvent(self.result_panel, PlotResultEvent(result=result)) 
    1570         # reset fit_engine if changed by simul_fit 
    1571         if self._fit_engine != self._gui_engine: 
    1572             self._on_change_engine(self._gui_engine) 
    15731482        self._update_fit_button(page_id) 
    15741483        result = result[0] 
     
    16671576                     StatusEvent(status=msg)) 
    16681577 
    1669     def _onset_engine_park(self, event): 
    1670         """  
    1671         set engine to park 
    1672         """ 
    1673         self._on_change_engine('park') 
    1674         
    1675     def _onset_engine_scipy(self, event): 
    1676         """  
    1677         set engine to scipy 
    1678         """ 
    1679         self._on_change_engine('scipy') 
    1680         
    1681     def _onset_engine_bumps(self, event): 
    1682         """  
    1683         set engine to bumps 
    1684         """ 
    1685         self._on_change_engine('bumps') 
    1686         
     1578 
    16871579    def _on_slicer_event(self, event): 
    16881580        """ 
     
    17051597        """ 
    17061598        name = event.GetEventObject().frame.GetTitle() 
    1707         print "name", name 
    17081599        for panel in self.slicer_panels: 
    17091600            if panel.window_caption == name: 
     
    17171608                break 
    17181609     
    1719     def _on_change_engine(self, engine='park'): 
    1720         """ 
    1721         Allow to select the type of engine to perform fit 
    1722          
    1723         :param engine: the key work of the engine 
    1724          
    1725         """ 
    1726         ## saving fit engine name 
    1727         self._fit_engine = engine 
    1728         ## change menu item state 
    1729         if engine == "park": 
    1730             self.menu1.FindItemById(self.park_id).Check(True) 
    1731             self.menu1.FindItemById(self.scipy_id).Check(False) 
    1732             self.menu1.FindItemById(self.bumps_id).Check(False) 
    1733         elif engine == "scipy": 
    1734             self.menu1.FindItemById(self.park_id).Check(False) 
    1735             self.menu1.FindItemById(self.scipy_id).Check(True) 
    1736             self.menu1.FindItemById(self.bumps_id).Check(False) 
    1737         else: 
    1738             self.menu1.FindItemById(self.park_id).Check(False) 
    1739             self.menu1.FindItemById(self.scipy_id).Check(False) 
    1740             self.menu1.FindItemById(self.bumps_id).Check(True) 
    1741         ## post a message to status bar 
    1742         msg = "Engine set to: %s" % self._fit_engine 
    1743         wx.PostEvent(self.parent, 
    1744                      StatusEvent(status=msg)) 
    1745         ## send the current engine type to fitpanel 
    1746         self.fit_panel._on_engine_change(name=self._fit_engine) 
    1747  
    17481610    def _on_model_panel(self, evt): 
    17491611        """ 
  • src/sas/perspectives/fitting/ftol_dialog.py

    rb9a5f0e r386ffe1  
    1313#copyright 2009, University of Tennessee 
    1414################################################################################ 
     15_ = """ 
    1516import wx 
    1617import sys 
     
    103104                return None 
    104105        return SAS_F_TOL 
     106""" 
  • src/sas/perspectives/fitting/simfitpage.py

    r79492222 r386ffe1  
    153153        ## making sure all parameters content a constraint 
    154154        ## validity of the constraint expression is own by fit engine 
    155         if self.parent._manager._fit_engine not in ("park","bumps") and flag: 
    156             msg = "The FitEnging will be set to 'Park' fit engine\n" 
    157             msg += " for the simultaneous fit..." 
    158             #wx.MessageBox(msg, 'Info') 
    159             wx.PostEvent(self._manager.parent, StatusEvent(status=\ 
    160                             "Fitting: %s" % msg, info="info")) 
    161155        if not self.batch_on and self.show_constraint.GetValue(): 
    162156            if not self._set_constraint(): 
     
    689683            text = " Fit in Parallel all Data set and model selected.\n" 
    690684        else: 
    691             text = "     Note: Park fitting engine will be used automatically. \n" 
    692             text += "     This page requires at least one FitPage with a data \n" 
    693             text += "       and a model set for fitting." 
    694             #text+= "automatically for more than 2 combinations checked" 
     685            text = " This page requires at least one FitPage with a data\n" 
     686            text = " and a model for fitting." 
    695687        text_hint = wx.StaticText(self, -1, text) 
    696688         
  • test/park_integration/test/batch_fit.py

    r35ec279 r386ffe1  
    4242        self.qmax = qmax 
    4343         
    44     def _reset_helper(self, path=None, engine="scipy", npts=NPTS): 
     44    def _reset_helper(self, path=None, engine="bumps", npts=NPTS): 
    4545        """ 
    4646        Set value to fitter engine and prepare inputs for map function 
     
    7777            self.list_of_mapper.append(classMapper) 
    7878                    
    79     def reset_value(self, engine='scipy'): 
     79    def reset_value(self, engine='bumps'): 
    8080        """ 
    8181        Initialize inputs for the map function 
  • test/park_integration/test/utest_fit_cylinder.py

    ra10364b r386ffe1  
    2727        self.pars1 =['length','radius','scale'] 
    2828         
    29     def _fit(self, name="scipy"): 
     29    def _fit(self, name="bumps"): 
    3030        """ return fit result """ 
    3131        fitter = Fit(name) 
     
    4545 
    4646 
    47     def test_scipy(self): 
    48         """ Simple cylinder model fit (scipy)  """ 
    49         self._fit("scipy") 
    50  
    51  
    52     def test_park(self): 
    53         """ Simple cylinder model fit (park)  """ 
    54         self._fit("park") 
    55  
    5647    def test_bumps(self): 
    57         """ Simple cylinder model fit (park)  """ 
     48        """ Simple cylinder model fit """ 
    5849        self._fit("bumps") 
    5950 
     
    9081 
    9182    def test_constrained_bumps(self): 
    92         """ Simultaneous cylinder model fit (park) """ 
     83        """ Simultaneous cylinder model fit """ 
    9384        self._run_fit(Fit('bumps')) 
    9485 
    9586    #@unittest.skip("") 
    96     def test_constrained_park(self): 
    97         """ Simultaneous cylinder model fit (park)  """ 
    98         self._run_fit(Fit('park')) 
    99  
    10087    def _run_fit(self, fitter): 
    10188        result1, result2 = self._fit(fitter) 
     
    10592 
    10693        for n, v, dv in zip(result1.param_list, result1.pvec, result1.stderr): 
    107             print "%s M1.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 
     94            #print "%s M1.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 
    10895            if n == "length": 
    10996                self.assertTrue( math.fabs(v-400.0)/3.0 < dv ) 
     
    113100                self.assertTrue( math.fabs(v-1.0)/3.0 < dv ) 
    114101        for n, v, dv in zip(result2.param_list, result2.pvec, result2.stderr): 
    115             print "%s M2.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 
     102            #print "%s M2.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 
    116103            if n=='radius': 
    117104                self.assertTrue( math.fabs(v-40.0)/3.0 < dv ) 
  • test/park_integration/test/utest_fit_line.py

    r35ec279 r386ffe1  
    3232            assert str(exc).startswith('parameter param1') 
    3333        else: 
    34             raise AssertionError("No error raised for scipy fitting with wrong parameters name to fit") 
     34            raise AssertionError("No error raised for fitting with wrong parameters name to fit") 
    3535 
    3636    def fit_single(self, fitter_name, isdream=False): 
     
    4545        model1.name = "M1" 
    4646        model = Model(model1,data) 
    47         #fit with scipy test 
    4847 
    4948        pars1= ['A','B'] 
     
    9291        self.fit_bumps('lm') 
    9392 
    94     def test_scipy(self): 
    95         #print "fitting scipy" 
    96         self.fit_single('scipy') 
    97  
    98     def test_park(self): 
    99         #print "fitting park" 
    100         self.fit_single('park') 
    101  
    102          
    10393    def test2(self): 
    10494        """ fit 2 data and 2 model with no constrainst""" 
     
    112102      
    113103        #Importing the Fit module 
    114         fitter = Fit('scipy') 
     104        fitter = Fit('bumps') 
    115105        # Receives the type of model for the fitting 
    116106        model11  = LineModel() 
     
    121111        model1 = Model(model11,data1) 
    122112        model2 = Model(model22,data2) 
    123         #fit with scipy test 
    124113        pars1= ['A','B'] 
    125114        fitter.set_data(data1,1) 
     
    129118        fitter.set_model(model2,2,pars1) 
    130119        fitter.select_problem_for_fit(id=2,value=0) 
    131          
     120 
    132121        try: result1, = fitter.fit(handler=FitHandler()) 
    133122        except RuntimeError,msg: 
    134            assert str(msg)=="No Assembly scheduled for Scipy fitting." 
    135         else: raise AssertionError,"No error raised for scipy fitting with no model" 
    136         fitter.select_problem_for_fit(id=1,value=1) 
    137         fitter.select_problem_for_fit(id=2,value=1) 
    138         try: result1, = fitter.fit(handler=FitHandler()) 
    139         except RuntimeError,msg: 
    140            assert str(msg)=="Scipy can't fit more than a single fit problem at a time." 
    141         else: raise AssertionError,"No error raised for scipy fitting with more than 2 models" 
    142  
    143         #fit with park test 
    144         fitter = Fit('park') 
    145         fitter.set_data(data1,1) 
    146         fitter.set_model(model1,1,pars1) 
    147         fitter.set_data(data2,2) 
    148         fitter.set_model(model2,2,pars1) 
     123            assert str(msg)=="Nothing to fit" 
     124        else: raise AssertionError,"No error raised for fitting with no model" 
    149125        fitter.select_problem_for_fit(id=1,value=1) 
    150126        fitter.select_problem_for_fit(id=2,value=1) 
     
    156132         
    157133         
    158     def test3(self): 
     134    def test_constraints(self): 
    159135        """ fit 2 data and 2 model with 1 constrainst""" 
    160136        #load data 
     
    180156        model1.set(B=3) 
    181157        # Constraint the constant value to be equal to parameter B (the real value is 2.5) 
    182         model2.set(value='line.B') 
    183         #fit with scipy test 
     158        #model2.set(value='line.B') 
    184159        pars1= ['A','B'] 
    185160        pars2= ['value'] 
    186161         
    187162        #Importing the Fit module 
    188         fitter = Fit('park') 
     163        fitter = Fit('bumps') 
    189164        fitter.set_data(data1,1) 
    190165        fitter.set_model(model1,1,pars1) 
    191166        fitter.set_data(data2,2,smearer=None) 
    192         fitter.set_model(model2,2,pars2) 
     167        fitter.set_model(model2,2,pars2,constraints=[("value","line.B")]) 
    193168        fitter.select_problem_for_fit(id=1,value=1) 
    194169        fitter.select_problem_for_fit(id=2,value=1) 
     
    216191        model = Model(model1,data1) 
    217192       
    218         #fit with scipy test 
    219         pars1= ['A','B'] 
    220         #Importing the Fit module 
    221         fitter = Fit('scipy') 
    222         fitter.set_data(data1,1,qmin=0, qmax=7) 
    223         fitter.set_model(model,1,pars1) 
    224         fitter.set_data(data2,1,qmin=1,qmax=10) 
    225         fitter.select_problem_for_fit(id=1,value=1) 
    226          
    227         result1, = fitter.fit(handler=FitHandler()) 
    228         #print(result1) 
    229         self.assert_(result1) 
    230  
    231         self.assertTrue( math.fabs(result1.pvec[0]-4)/3 <= result1.stderr[0] ) 
    232         self.assertTrue( math.fabs(result1.pvec[1]-2.5)/3 <= result1.stderr[1]) 
    233         self.assertTrue( result1.fitness/len(data1.x) < 2 ) 
    234  
    235         #fit with park test 
    236         fitter = Fit('park') 
     193        pars1= ['A','B'] 
     194        #Importing the Fit module 
     195 
     196        fitter = Fit('bumps') 
    237197        fitter.set_data(data1,1,qmin=0, qmax=7) 
    238198        fitter.set_model(model,1,pars1) 
     
    245205        self.assertTrue( math.fabs(result2.pvec[1]-2.5)/3 <= result2.stderr[1] ) 
    246206        self.assertTrue( result2.fitness/len(data1.x) < 2) 
    247         # compare fit result result for scipy and park 
    248         self.assertAlmostEquals( result1.pvec[0], result2.pvec[0] ) 
    249         self.assertAlmostEquals( result1.pvec[1],result2.pvec[1] ) 
    250         self.assertAlmostEquals( result1.stderr[0],result2.stderr[0] ) 
    251         self.assertAlmostEquals( result1.stderr[1],result2.stderr[1] ) 
    252         self.assertTrue( result2.fitness/(len(data2.x)+len(data1.x)) < 2 ) 
    253207 
    254208 
  • test/park_integration/test/utest_fit_smeared.py

    r35ec279 r386ffe1  
    1717    """ test fitting """ 
    1818     
    19     def test_scipy(self): 
    20         """ Simple cylinder model fit (scipy) """ 
     19    def test_without_resolution(self): 
     20        """ Simple cylinder model fit """ 
    2121         
    2222        out=Loader().load("cyl_400_20.txt") 
     
    2424        #out.dy = out.y 
    2525         
    26         fitter = Fit('scipy') 
     26        fitter = Fit('bumps') 
    2727        fitter.set_data(out,1) 
    2828         
     
    5353        self.assertTrue( result1.fitness < 1.0 ) 
    5454 
    55     def test_park_dispersion(self): 
    56         """ 
    57             Cylinder fit with dispersion 
    58         """ 
    59         self._dispersion(fitter = Fit('park')) 
    60  
    61     def test_bumps_dispersion(self): 
     55    def test_dispersion(self): 
    6256        """ 
    6357            Cylinder fit with dispersion 
     
    6963        fitters.FIT_OPTIONS[alg].options.update(monitors=[]) 
    7064        self._dispersion(fitter = Fit('bumps')) 
    71  
    72     def test_scipy_dispersion(self): 
    73         """ 
    74             Cylinder fit with dispersion 
    75         """ 
    76         self._dispersion(fitter = Fit('scipy')) 
    7765 
    7866    def _dispersion(self, fitter): 
     
    148136 
    149137        # Fit 
    150         fitter = Fit('scipy') 
     138        fitter = Fit('bumps') 
    151139         
    152140        # Data: right now this is the only way to set the smearer object 
     
    179167        self.assertEqual(smear.__class__.__name__, 'SlitSmearer') 
    180168 
    181         fitter = Fit('scipy') 
     169        fitter = Fit('bumps') 
    182170         
    183171        # Data: right now this is the only way to set the smearer object 
  • test/park_integration/test/utest_small_test.py

    r35ec279 r386ffe1  
    66from sas.fit.Fitting import Fit 
    77from sas.dataloader.loader import Loader 
     8import bumps.fitters 
     9bumps.fitters.FIT_DEFAULT = 'lm' 
    810 
    911class testFitModule(unittest.TestCase): 
    1012    """ test fitting """ 
    11     def test_park(self): 
    12         """ Simple cylinder model fit (scipy)  """ 
     13    def test_cylinder_fit(self): 
     14        """ Simple cylinder model fit """ 
    1315         
    1416        out= Loader().load("cyl_400_20.txt") 
    1517        
    16         fitter = Fit('scipy') 
     18        fitter = Fit('bumps') 
    1719        # Receives the type of model for the fitting 
    1820        from sas.models.CylinderModel import CylinderModel 
     
    2022        model.setParam('sldCyl', 1) 
    2123        model.setParam('sldSolv', 0) 
     24        model.setParam('scale', 1e-10) 
    2225 
    2326        pars1 =['length','radius','scale'] 
    2427        fitter.set_data(out,1) 
    25         model.setParam('scale', 1e-10) 
    2628        fitter.set_model(model,1,pars1, constraints=()) 
    2729        fitter.select_problem_for_fit(id=1,value=1) 
     
    3335        self.assertTrue(len(result1.pvec)>0 or len(result1.pvec)==0 ) 
    3436        self.assertTrue(len(result1.stderr)> 0 or len(result1.stderr)==0) 
    35          
    36         #print result1.pvec[0]-400.0, result1.pvec[0] 
    37         #print math.fabs(result1.pvec[0]-400.0)/3.0 
     37 
    3838        self.assertTrue( math.fabs(result1.pvec[0]-400.0)/3.0 < result1.stderr[0] ) 
    3939        self.assertTrue( math.fabs(result1.pvec[1]-20.0)/3.0  < result1.stderr[1] ) 
  • test/pr_inversion/test/test_output.txt

    r400155b r386ffe1  
    33#alpha=0.0007 
    44#chi2=836.797 
    5 #elapsed=0 
     5#elapsed=0.00100017 
    66#qmin=None 
    77#qmax=None 
  • test/sasmodels/test/utest_models.py

    r8c9ffde r386ffe1  
    5959      
    6060    def test2D(self): 
    61         """ Test 2D model of a cylinder """  
     61        """ Test 2D model of a cylinder """ 
    6262        self.comp.setParam('cyl_theta', 10.0) 
    6363        self.comp.setParam('cyl_phi', 10.0) 
    64         self.assertAlmostEqual(self.comp.run([0.2, 2.5]),  
    65                                0.038176446608393366, 2)  
     64        self.assertAlmostEqual(self.comp.run([0.2, 2.5]), 
     65                               0.038176446608393366, 2) 
    6666  
    6767class TestGaussian(unittest.TestCase): 
Note: See TracChangeset for help on using the changeset viewer.