Changeset ad6dd4c in sasview


Ignore:
Timestamp:
Apr 24, 2009 4: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

Location:
sansview/perspectives/fitting
Files:
3 edited

Legend:

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

    r1c1436d rad6dd4c  
    139139            handler= ConsoleUpdate(parent= self.parent,improvement_delta=0.1) 
    140140            #Result from the fit 
    141             result = self.fitter.fit(handler= handler) 
     141            result = self.fitter.fit(handler= handler, curr_thread=self) 
    142142         
    143143            elapsed = time.time()-self.starttime 
     
    150150            # Thread was interrupted, just proceed and re-raise. 
    151151            # Real code should not print, but this is an example... 
     152            #print "keyboard exception" 
    152153            raise 
    153        
     154         
     155        except : 
     156            #print "uncaught exception" 
     157            raise 
    154158     
  • 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() 
  • sansview/perspectives/fitting/fitting.py

    r813334e rad6dd4c  
    354354            Stop the fit engine 
    355355        """ 
    356         if self.calc_fit!= None and self.calc_thread.isrunning(): 
    357             self.calc_thread.stop() 
     356        if self.calc_fit!= None and self.calc_fit.isrunning(): 
     357            self.calc_fit.stop() 
    358358            wx.PostEvent(self.parent, StatusEvent(status="Fitting  \ 
    359359                is cancelled" , type="stop")) 
     
    681681       
    682682        try: 
     683            if result ==None: 
     684                msg= "Simple Fitting Stop !!!" 
     685                wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 
     686                return 
    683687            if numpy.any(result.pvec ==None )or not numpy.all(numpy.isfinite(result.pvec) ): 
    684                 msg= "Fitting did not converge!!!" 
     688                msg= "Single Fitting did not converge!!!" 
    685689                wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 
    686690                return 
     
    727731        ## fit more than 1 model at the same time  
    728732        try: 
     733            if result ==None: 
     734                msg= "Complex Fitting Stop !!!" 
     735                wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 
     736                return 
     737            if numpy.any(result.pvec ==None )or not numpy.all(numpy.isfinite(result.pvec) ): 
     738                msg= "Single Fitting did not converge!!!" 
     739                wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 
     740                return 
    729741            for page, value in self.page_finder.iteritems(): 
    730742                if value.get_scheduled()==1: 
Note: See TracChangeset for help on using the changeset viewer.