source: sasview/sansview/perspectives/fitting/fit_thread.py @ 25952cd

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 25952cd was 40953a9, checked in by Jae Cho <jhjcho@…>, 14 years ago

slightly better FitAbort? msg

  • Property mode set to 100644
File size: 2.2 KB
Line 
1
2import sys
3from data_util.calcthread import CalcThread
4
5
6class FitThread(CalcThread):
7    """Thread performing the fit """
8   
9    def __init__(self, 
10                  fn,
11                  page_id,
12                   handler,
13                  pars=None,
14                 completefn = None,
15                 updatefn   = None,
16                 yieldtime  = 0.01,
17                 worktime   = 0.01,
18                 ftol       = None):
19        CalcThread.__init__(self,completefn,
20                 updatefn,
21                 yieldtime,
22                 worktime)
23        self.handler = handler
24        self.fitter = fn
25        self.pars = pars
26        self.page_id = page_id
27        self.starttime = 0
28        self.updatefn = updatefn
29        #Relative error desired in the sum of squares.
30        self.ftol = ftol
31   
32    def isquit(self):
33        """
34        :raise KeyboardInterrupt: when the thread is interrupted
35       
36        """
37        try:
38            CalcThread.isquit(self)
39        except KeyboardInterrupt:
40            raise KeyboardInterrupt
41       
42    def compute(self):
43        """
44        Perform a fit
45        """
46        msg = ""
47        try: 
48            #self.handler.starting_fit()
49            #Result from the fit
50            result = self.fitter.fit(handler=self.handler, 
51                                     curr_thread=self,
52                                     ftol=self.ftol)
53            self.complete(result= result,
54                          page_id=self.page_id,
55                          pars = self.pars)
56           
57        except KeyboardInterrupt, msg:
58            # Thread was interrupted, just proceed and re-raise.
59            # Real code should not print, but this is an example...
60            #print "keyboard exception"
61            #Stop on exception during fitting. Todo: need to put some mssg and reset progress bar.
62            raise
63            #if self.handler is not None:
64            #    self.handler.error(msg=msg)
65        except:
66            raise
67            #if self.handler is not None:
68            #    self.handler.error(msg=str(sys.exc_value))
69           
70       
71   
Note: See TracBrowser for help on using the repository browser.