source: sasview/sansview/perspectives/fitting/fit_thread.py @ a0da535

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 a0da535 was 5062bbf, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working on documentation

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