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 5cc39f10 was
66ff250,
checked in by Gervaise Alina <gervyh@…>, 14 years ago
|
working on fit stop
|
-
Property mode set to
100644
|
File size:
2.0 KB
|
Rev | Line | |
---|
[e9b4cc4] | 1 | |
---|
[66ff250] | 2 | import sys |
---|
[e54d2c32] | 3 | from data_util.calcthread import CalcThread |
---|
[e9b4cc4] | 4 | |
---|
[66ff250] | 5 | |
---|
[e9b4cc4] | 6 | class FitThread(CalcThread): |
---|
[ed2ea6a] | 7 | """Thread performing the fit """ |
---|
[e9b4cc4] | 8 | |
---|
[e54d2c32] | 9 | def __init__(self, parent, |
---|
| 10 | fn, |
---|
[66ff250] | 11 | page_id, |
---|
[e54d2c32] | 12 | handler, |
---|
| 13 | pars=None, |
---|
[e9b4cc4] | 14 | completefn = None, |
---|
| 15 | updatefn = None, |
---|
| 16 | yieldtime = 0.01, |
---|
| 17 | worktime = 0.01 |
---|
| 18 | ): |
---|
| 19 | CalcThread.__init__(self,completefn, |
---|
| 20 | updatefn, |
---|
| 21 | yieldtime, |
---|
| 22 | worktime) |
---|
| 23 | self.parent = parent |
---|
[e54d2c32] | 24 | self.handler = handler |
---|
| 25 | self.fitter = fn |
---|
[e9b4cc4] | 26 | self.pars = pars |
---|
[66ff250] | 27 | self.page_id = page_id |
---|
[e9b4cc4] | 28 | self.starttime = 0 |
---|
[e54d2c32] | 29 | self.updatefn = updatefn |
---|
| 30 | |
---|
[e9b4cc4] | 31 | def isquit(self): |
---|
[ed2ea6a] | 32 | """ |
---|
[5062bbf] | 33 | :raise KeyboardInterrupt: when the thread is interrupted |
---|
| 34 | |
---|
[ed2ea6a] | 35 | """ |
---|
[e9b4cc4] | 36 | try: |
---|
| 37 | CalcThread.isquit(self) |
---|
| 38 | except KeyboardInterrupt: |
---|
| 39 | raise KeyboardInterrupt |
---|
[66ff250] | 40 | |
---|
[e9b4cc4] | 41 | def compute(self): |
---|
[ed2ea6a] | 42 | """ |
---|
[5062bbf] | 43 | Perform a fit |
---|
[ed2ea6a] | 44 | """ |
---|
[e9b4cc4] | 45 | try: |
---|
[66ff250] | 46 | #self.handler.starting_fit() |
---|
[ed2ea6a] | 47 | #Result from the fit |
---|
[e54d2c32] | 48 | result = self.fitter.fit(handler=self.handler, curr_thread=self) |
---|
[e9b4cc4] | 49 | self.complete(result= result, |
---|
[66ff250] | 50 | page_id=self.page_id, |
---|
[6bbeacd4] | 51 | pars = self.pars) |
---|
[785c8233] | 52 | |
---|
[e54d2c32] | 53 | except KeyboardInterrupt, msg: |
---|
[e9b4cc4] | 54 | # Thread was interrupted, just proceed and re-raise. |
---|
| 55 | # Real code should not print, but this is an example... |
---|
[ad6dd4c] | 56 | #print "keyboard exception" |
---|
[a6a7e8a] | 57 | #Stop on exception during fitting. Todo: need to put some mssg and reset progress bar. |
---|
[66ff250] | 58 | raise |
---|
| 59 | #if self.handler is not None: |
---|
| 60 | # self.handler.error(msg=msg) |
---|
| 61 | except: |
---|
| 62 | raise |
---|
| 63 | #if self.handler is not None: |
---|
| 64 | # self.handler.error(msg=str(sys.exc_value)) |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | |
---|
Note: See
TracBrowser
for help on using the repository browser.