source: sasview/sansview/perspectives/fitting/fit_thread.py @ 9e8c150

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 9e8c150 was e54d2c32, checked in by Gervaise Alina <gervyh@…>, 15 years ago

working on status bar display for fit

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