Ignore:
Timestamp:
Apr 24, 2009 2:40:05 PM (15 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:
da26c1a
Parents:
4bd557d
Message:

working on stopping scipy fit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/fitpage.py

    r813334e rad6dd4c  
    6868        if len(self.parameters)==0: 
    6969            return 
     70        if event.type =="park": 
     71            self.btFit.SetLabel("Fit") 
    7072        for item in self.parameters: 
    7173            if event.type =="scipy": 
     
    454456            Allow to fit 
    455457        """ 
    456         #self.btFit.SetLabel("Stop") 
    457458        from sans.guiframe.utils import check_value 
    458459        flag = check_value( self.qmin, self.qmax)  
     
    469470 
    470471        # Remove or do not allow fitting on the Q=0 point, especially when y(q=0)=None at x[0]. 
    471         #ToDo: Fix this. 
    472         #if float(self.qmin.GetValue())==0.0 and self.data.x[0]==0 and not numpy.isfinite(self.data.y[0]): 
    473         #    self.qmin_x = min(self.data.x[self.data.x!=0]) 
    474         #else:                        
     472        #ToDo: Fix this.                 
    475473        self.qmin_x = float(self.qmin.GetValue()) 
    476          
    477474        self.qmax_x =float( self.qmax.GetValue()) 
    478475        self.manager._reset_schedule_problem( value=0) 
    479476        self.manager.schedule_for_fit( value=1,page=self,fitproblem =None)  
    480477        self.manager.set_fit_range(page= self,qmin= self.qmin_x, qmax= self.qmax_x) 
     478         
    481479        #single fit  
    482480        self.manager.onFit() 
     481        ## allow stopping the fit  
     482        if self.engine_type=="scipy": 
     483            self.btFit.SetLabel("Stop") 
     484            self.btFit.Unbind(event=wx.EVT_BUTTON, id= self.btFit.GetId()) 
     485            self.btFit.Bind(event= wx.EVT_BUTTON, handler=self._StopFit, id=self.btFit.GetId()) 
     486        else: 
     487            self.btFit.SetLabel("Fit") 
     488            self.btFit.Bind(event= wx.EVT_BUTTON, handler=self._onFit, id=self.btFit.GetId()) 
    483489        self.btFit.SetFocus()     
    484490        self.sizer5.Layout() 
    485491        self.SetScrollbars(20,20,55,40) 
    486492         
    487          
     493    def _StopFit(self, event): 
     494        """ 
     495            Stop fit  
     496        """ 
     497        self.btFit.SetLabel("Fit") 
     498        if self.engine_type=="scipy": 
     499            self.manager.stop_fit() 
     500            self.btFit.Unbind(event=wx.EVT_BUTTON, id=self.btFit.GetId()) 
     501            self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._onFit,id=self.btFit.GetId()) 
     502        else: 
     503            self.btFit.Unbind(event=wx.EVT_BUTTON, id=self.btFit.GetId()) 
     504            self.btFit.Bind(event= wx.EVT_BUTTON, handler=self._onFit, id=self.btFit.GetId()) 
     505        self.btFit.SetFocus()     
     506        self.sizer5.Layout() 
     507        self.SetScrollbars(20,20,55,40)     
     508             
    488509    def _on_select_model(self, event):  
    489510        """ 
     
    619640                except: 
    620641                    pass 
    621                 if cov[0]==None:  
     642                if cov[0]==None or  not numpy.isfinite(cov[0]):  
    622643                    self.param_toFit[0][3].Hide() 
    623644                    self.param_toFit[0][4].Clear() 
     
    658679                            break 
    659680                    ## unable to compare cov[j]==numpy.nan so switch to None 
    660                     if cov[j]==None: 
     681                    if cov[j]==None or not numpy.isfinite(cov[j]): 
    661682                        item[3].Hide() 
    662683                        item[4].Refresh() 
Note: See TracChangeset for help on using the changeset viewer.