source: sasview/sansview/perspectives/fitting/fit_thread.py @ 552b3d5

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 552b3d5 was 6bbeacd4, checked in by Gervaise Alina <gervyh@…>, 14 years ago

remove other type of data

  • Property mode set to 100644
File size: 1.7 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                 completefn = None,
13                 updatefn   = None,
14                 yieldtime  = 0.01,
15                 worktime   = 0.01
16                 ):
17        CalcThread.__init__(self,completefn,
18                 updatefn,
19                 yieldtime,
20                 worktime)
21        self.parent = parent
22        self.handler = handler
23        self.fitter = fn
24        self.pars = pars
25        self.starttime = 0
26        self.updatefn = updatefn
27   
28    def isquit(self):
29        """
30        :raise KeyboardInterrupt: when the thread is interrupted
31       
32        """
33        try:
34            CalcThread.isquit(self)
35        except KeyboardInterrupt:
36            raise KeyboardInterrupt
37       
38    def compute(self):
39        """
40        Perform a fit
41        """
42        try: 
43            self.handler.starting_fit()
44            self.updatefn()
45            #Result from the fit
46            result = self.fitter.fit(handler=self.handler, curr_thread=self)
47            self.updatefn()
48            self.complete(result= result,
49                          pars = self.pars)
50           
51        except KeyboardInterrupt, msg:
52            # Thread was interrupted, just proceed and re-raise.
53            # Real code should not print, but this is an example...
54            #print "keyboard exception"
55            #Stop on exception during fitting. Todo: need to put some mssg and reset progress bar.
56            self.handler.error(msg=msg)
57       
Note: See TracBrowser for help on using the repository browser.