Changeset 3c6ecd9 in sasview for src/sas/qtgui/Perspectives/Fitting


Ignore:
Timestamp:
May 7, 2018 4:47:21 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
42787fb
Parents:
b0ba43e (diff), 80468f6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ESS_GUI' into ESS_GUI_Pr

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
15 edited
20 moved

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/ComplexConstraint.py

    r725d9c06 raed0532  
    202202        try: 
    203203            help_location = GuiUtils.HELP_DIRECTORY_LOCATION + \ 
    204             "/user/sasgui/perspectives/fitting/fitting_help.html#simultaneous-fits-with-constraints" 
     204            "/user/qtgui/Perspectives/Fitting/fitting_help.html#simultaneous-fits-with-constraints" 
    205205            webbrowser.open('file://' + os.path.realpath(help_location)) 
    206206        except AttributeError: 
  • src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py

    r8b480d27 raed0532  
    230230        Show the "Fitting" section of help 
    231231        """ 
    232         tree_location = "/user/sasgui/perspectives/fitting/" 
     232        tree_location = "/user/qtgui/Perspectives/Fitting/" 
    233233 
    234234        helpfile = "fitting_help.html#simultaneous-fit-mode" 
     
    358358        elapsed = result[1] 
    359359 
    360         # ADD THE BATCH FIT VIEW HERE 
    361         # 
     360        if result is None: 
     361            msg = "Fitting failed." 
     362            self.parent.communicate.statusBarUpdateSignal.emit(msg) 
     363            return 
     364 
     365        # Show the grid panel 
     366        self.parent.communicate.sendDataToGridSignal.emit(result[0]) 
    362367 
    363368        msg = "Fitting completed successfully in: %s s.\n" % GuiUtils.formatNumber(elapsed) 
  • src/sas/qtgui/Perspectives/Fitting/FittingLogic.py

    • Property mode changed from 100755 to 100644
    rb3e8629 rd6e38661  
    126126 
    127127        new_plot.group_id = data.group_id 
    128         new_plot.id = str(tab_id) + " " + data.name 
    129         new_plot.name = model.name + " [" + data.name + "]" 
     128        new_plot.id = str(tab_id) + " " + model.id 
     129 
     130        if data.filename: 
     131            new_plot.name = model.name + " [" + data.filename + "]" # data file 
     132        else: 
     133            new_plot.name = model.name + " [" + model.id + "]"  # theory 
     134 
    130135        new_plot.title = new_plot.name 
    131136        new_plot.xaxis(_xaxis, _xunit) 
  • src/sas/qtgui/Perspectives/Fitting/FittingOptions.py

    re90988c raed0532  
    158158        """ 
    159159        tree_location = GuiUtils.HELP_DIRECTORY_LOCATION 
    160         tree_location += "/user/sasgui/perspectives/fitting/" 
     160        tree_location += "/user/qtgui/Perspectives/Fitting/" 
    161161 
    162162        # Actual file anchor will depend on the combo box index 
  • src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py

    rfde5bcd rb5cc06e  
    6868    multishell_parameters = getIterParams(parameters) 
    6969    multishell_param_name, _ = getMultiplicity(parameters) 
    70     params = parameters.iqxy_parameters if is2D else parameters.iq_parameters 
     70    if is2D: 
     71        params = [p for p in parameters.kernel_parameters if p.type != 'magnetic'] 
     72    else: 
     73        params = parameters.iq_parameters 
    7174    item = [] 
    7275    for param in params: 
     
    125128    Update local ModelModel with sasmodel parameters 
    126129    """ 
    127     params = parameters.iqxy_parameters if is2D else parameters.iq_parameters 
     130    if is2D: 
     131        params = [p for p in parameters.kernel_parameters if p.type != 'magnetic'] 
     132    else: 
     133        params = parameters.iq_parameters 
    128134    item = [] 
    129135    for param in params: 
     
    421427        weight = numpy.abs(data) 
    422428    return weight 
     429 
     430def updateKernelWithResults(kernel, results): 
     431    """ 
     432    Takes model kernel and applies results dict to its parameters, 
     433    returning the modified (deep) copy of the kernel. 
     434    """ 
     435    assert(isinstance(results, dict)) 
     436    local_kernel = copy.deepcopy(kernel) 
     437 
     438    for parameter in results.keys(): 
     439        # Update the parameter value - note: this supports +/-inf as well 
     440        local_kernel.setParam(parameter, results[parameter][0]) 
     441 
     442    return local_kernel 
     443 
     444 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r8b480d27 raed0532  
    33from collections import defaultdict 
    44 
    5  
     5import copy 
    66import logging 
    77import traceback 
     
    2424import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    2525import sas.qtgui.Utilities.LocalConfig as LocalConfig 
    26 from sas.qtgui.Utilities.GridPanel import BatchOutputPanel 
    2726from sas.qtgui.Utilities.CategoryInstaller import CategoryInstaller 
    2827from sas.qtgui.Plotting.PlotterData import Data1D 
     
    8887    fittingFinishedSignal = QtCore.pyqtSignal(tuple) 
    8988    batchFittingFinishedSignal = QtCore.pyqtSignal(tuple) 
     89    Calc1DFinishedSignal = QtCore.pyqtSignal(tuple) 
     90    Calc2DFinishedSignal = QtCore.pyqtSignal(tuple) 
    9091 
    9192    def __init__(self, parent=None, data=None, tab_id=1): 
     
    99100        self.tab_id = tab_id 
    100101 
    101         # Main Data[12]D holder 
    102         self.logic = FittingLogic() 
    103  
    104102        # Globals 
    105103        self.initializeGlobals() 
     
    107105        # Set up desired logging level 
    108106        logging.disable(LocalConfig.DISABLE_LOGGING) 
     107 
     108        # data index for the batch set 
     109        self.data_index = 0 
     110        # Main Data[12]D holders 
     111        # Logics.data contains a single Data1D/Data2D object 
     112        self._logic = [FittingLogic()] 
    109113 
    110114        # Main GUI setup up 
     
    134138        self.initializeControls() 
    135139 
    136         # Display HTML content 
    137         #self.setupHelp() 
     140        if data is not None: 
     141            self.data = data 
    138142 
    139143        # New font to display angstrom symbol 
     
    142146        self.label_19.setStyleSheet(new_font) 
    143147 
    144         self._index = None 
    145         if data is not None: 
    146             self.data = data 
     148    @property 
     149    def logic(self): 
     150        # make sure the logic contains at least one element 
     151        assert(self._logic) 
     152        # logic connected to the currently shown data 
     153        return self._logic[self.data_index] 
    147154 
    148155    @property 
     
    161168 
    162169        assert isinstance(value[0], QtGui.QStandardItem) 
    163         # _index contains the QIndex with data 
    164         self._index = value[0] 
    165170 
    166171        # Keep reference to all datasets for batch 
    167172        self.all_data = value 
    168173 
    169         # Update logics with data items 
     174        # Create logics with data items 
     175        self._logic=[] 
    170176        # Logics.data contains only a single Data1D/Data2D object 
    171         self.logic.data = GuiUtils.dataFromItem(value[0]) 
     177        for data_item in value: 
     178            self._logic.append(FittingLogic()) 
     179            self._logic[-1].data = GuiUtils.dataFromItem(data_item) 
    172180 
    173181        # Overwrite data type descriptor 
     
    191199        self.is_batch_fitting = False 
    192200        self.is_chain_fitting = False 
     201        # Is the fit job running? 
     202        self.fit_started=False 
     203        # The current fit thread 
     204        self.calc_fit = None 
    193205        # Current SasModel in view 
    194206        self.kernel_module = None 
     
    222234        # Polydisp widget table default index for function combobox 
    223235        self.orig_poly_index = 3 
     236        # copy of current kernel model 
     237        self.kernel_module_copy = None 
    224238 
    225239        # Page id for fitting 
     
    484498        self.batchFittingFinishedSignal.connect(self.batchFitComplete) 
    485499        self.fittingFinishedSignal.connect(self.fitComplete) 
     500        self.Calc1DFinishedSignal.connect(self.complete1D) 
     501        self.Calc2DFinishedSignal.connect(self.complete2D) 
    486502 
    487503        # Signals from separate tabs asking for replot 
     
    926942        Update the logic based on the selected file in batch fitting 
    927943        """ 
    928         self._index = self.all_data[data_index] 
    929         self.logic.data = GuiUtils.dataFromItem(self.all_data[data_index]) 
     944        self.data_index = data_index 
    930945        self.updateQRange() 
    931946 
     
    11651180        Show the "Fitting" section of help 
    11661181        """ 
    1167         tree_location = "/user/sasgui/perspectives/fitting/" 
     1182        tree_location = "/user/qtgui/Perspectives/Fitting/" 
    11681183 
    11691184        # Actual file will depend on the current tab 
     
    12001215        Perform fitting on the current data 
    12011216        """ 
     1217        if self.fit_started: 
     1218            self.stopFit() 
     1219            return 
     1220 
    12021221        # initialize fitter constants 
    12031222        fit_id = 0 
     
    12231242            return 
    12241243 
     1244        # keep local copy of kernel parameters, as they will change during the update 
     1245        self.kernel_module_copy = copy.deepcopy(self.kernel_module) 
     1246 
    12251247        # Create the fitting thread, based on the fitter 
    12261248        completefn = self.batchFittingCompleted if self.is_batch_fitting else self.fittingCompleted 
    12271249 
    1228         calc_fit = FitThread(handler=handler, 
     1250        self.calc_fit = FitThread(handler=handler, 
    12291251                            fn=fitters, 
    12301252                            batch_inputs=batch_inputs, 
     
    12371259        if LocalConfig.USING_TWISTED: 
    12381260            # start the trhrhread with twisted 
    1239             calc_thread = threads.deferToThread(calc_fit.compute) 
     1261            calc_thread = threads.deferToThread(self.calc_fit.compute) 
    12401262            calc_thread.addCallback(completefn) 
    12411263            calc_thread.addErrback(self.fitFailed) 
    12421264        else: 
    12431265            # Use the old python threads + Queue 
    1244             calc_fit.queue() 
    1245             calc_fit.ready(2.5) 
     1266            self.calc_fit.queue() 
     1267            self.calc_fit.ready(2.5) 
    12461268 
    12471269        self.communicate.statusBarUpdateSignal.emit('Fitting started...') 
     1270        self.fit_started = True 
    12481271        # Disable some elements 
    12491272        self.setFittingStarted() 
    12501273 
     1274    def stopFit(self): 
     1275        """ 
     1276        Attempt to stop the fitting thread 
     1277        """ 
     1278        if self.calc_fit is None or not self.calc_fit.isrunning(): 
     1279            return 
     1280        self.calc_fit.stop() 
     1281        #self.fit_started=False 
     1282        #re-enable the Fit button 
     1283        self.setFittingStopped() 
     1284 
     1285        msg = "Fitting cancelled." 
     1286        self.communicate.statusBarUpdateSignal.emit(msg) 
     1287 
    12511288    def updateFit(self): 
    12521289        """ 
     
    12581295        """ 
    12591296        """ 
    1260         print("FIT FAILED: ", reason) 
    1261         pass 
     1297        self.setFittingStopped() 
     1298        msg = "Fitting failed with: "+ str(reason) 
     1299        self.communicate.statusBarUpdateSignal.emit(msg) 
    12621300 
    12631301    def batchFittingCompleted(self, result): 
     
    12701308        """ 
    12711309        Receive and display batch fitting results 
    1272         """ 
    1273         #re-enable the Fit button 
    1274         self.setFittingStopped() 
    1275         # Show the grid panel 
    1276         self.grid_window = BatchOutputPanel(parent=self, output_data=result[0]) 
    1277         self.grid_window.show() 
    1278  
    1279     def fittingCompleted(self, result): 
    1280         """ 
    1281         Send the finish message from calculate threads to main thread 
    1282         """ 
    1283         self.fittingFinishedSignal.emit(result) 
    1284  
    1285     def fitComplete(self, result): 
    1286         """ 
    1287         Receive and display fitting results 
    1288         "result" is a tuple of actual result list and the fit time in seconds 
    12891310        """ 
    12901311        #re-enable the Fit button 
     
    12961317            return 
    12971318 
    1298         res_list = result[0][0] 
    1299         res = res_list[0] 
    1300         if res.fitness is None or \ 
    1301             not np.isfinite(res.fitness) or \ 
    1302             np.any(res.pvec is None) or \ 
    1303             not np.all(np.isfinite(res.pvec)): 
    1304             msg = "Fitting did not converge!" 
    1305             self.communicate.statusBarUpdateSignal.emit(msg) 
    1306             msg += res.mesg 
    1307             logging.error(msg) 
    1308             return 
     1319        # Show the grid panel 
     1320        self.communicate.sendDataToGridSignal.emit(result[0]) 
    13091321 
    13101322        elapsed = result[1] 
     
    13121324        self.communicate.statusBarUpdateSignal.emit(msg) 
    13131325 
    1314         self.chi2 = res.fitness 
    1315         param_list = res.param_list # ['radius', 'radius.width'] 
    1316         param_values = res.pvec     # array([ 0.36221662,  0.0146783 ]) 
    1317         param_stderr = res.stderr   # array([ 1.71293015,  1.71294233]) 
     1326        # Run over the list of results and update the items 
     1327        for res_index, res_list in enumerate(result[0]): 
     1328            # results 
     1329            res = res_list[0] 
     1330            param_dict = self.paramDictFromResults(res) 
     1331 
     1332            # create local kernel_module 
     1333            kernel_module = FittingUtilities.updateKernelWithResults(self.kernel_module, param_dict) 
     1334            # pull out current data 
     1335            data = self._logic[res_index].data 
     1336 
     1337            # Switch indexes 
     1338            self.onSelectBatchFilename(res_index) 
     1339 
     1340            method = self.complete1D if isinstance(self.data, Data1D) else self.complete2D 
     1341            self.calculateQGridForModelExt(data=data, model=kernel_module, completefn=method, use_threads=False) 
     1342 
     1343        # Restore original kernel_module, so subsequent fits on the same model don't pick up the new params 
     1344        if self.kernel_module is not None: 
     1345            self.kernel_module = copy.deepcopy(self.kernel_module_copy) 
     1346 
     1347    def paramDictFromResults(self, results): 
     1348        """ 
     1349        Given the fit results structure, pull out optimized parameters and return them as nicely 
     1350        formatted dict 
     1351        """ 
     1352        if results.fitness is None or \ 
     1353            not np.isfinite(results.fitness) or \ 
     1354            np.any(results.pvec is None) or \ 
     1355            not np.all(np.isfinite(results.pvec)): 
     1356            msg = "Fitting did not converge!" 
     1357            self.communicate.statusBarUpdateSignal.emit(msg) 
     1358            msg += results.mesg 
     1359            logging.error(msg) 
     1360            return 
     1361 
     1362        param_list = results.param_list # ['radius', 'radius.width'] 
     1363        param_values = results.pvec     # array([ 0.36221662,  0.0146783 ]) 
     1364        param_stderr = results.stderr   # array([ 1.71293015,  1.71294233]) 
    13181365        params_and_errors = list(zip(param_values, param_stderr)) 
    13191366        param_dict = dict(zip(param_list, params_and_errors)) 
     1367 
     1368        return param_dict 
     1369 
     1370    def fittingCompleted(self, result): 
     1371        """ 
     1372        Send the finish message from calculate threads to main thread 
     1373        """ 
     1374        self.fittingFinishedSignal.emit(result) 
     1375 
     1376    def fitComplete(self, result): 
     1377        """ 
     1378        Receive and display fitting results 
     1379        "result" is a tuple of actual result list and the fit time in seconds 
     1380        """ 
     1381        #re-enable the Fit button 
     1382        self.setFittingStopped() 
     1383 
     1384        if result is None: 
     1385            msg = "Fitting failed." 
     1386            self.communicate.statusBarUpdateSignal.emit(msg) 
     1387            return 
     1388 
     1389        res_list = result[0][0] 
     1390        res = res_list[0] 
     1391        self.chi2 = res.fitness 
     1392        param_dict = self.paramDictFromResults(res) 
     1393 
     1394        elapsed = result[1] 
     1395        if self.calc_fit._interrupting: 
     1396            msg = "Fitting cancelled by user after: %s s." % GuiUtils.formatNumber(elapsed) 
     1397            logging.warning("\n"+msg+"\n") 
     1398        else: 
     1399            msg = "Fitting completed successfully in: %s s." % GuiUtils.formatNumber(elapsed) 
     1400        self.communicate.statusBarUpdateSignal.emit(msg) 
    13201401 
    13211402        # Dictionary of fitted parameter: value, error 
     
    19572038            self.updateModelIndex(fitted_data) 
    19582039        else: 
    1959             name = self.nameForFittedData(self.kernel_module.name) 
     2040            name = self.nameForFittedData(self.kernel_module.id) 
    19602041            fitted_data.title = name 
    19612042            fitted_data.name = name 
     
    19732054            fitted_data.symbol = 'Line' 
    19742055        # Notify the GUI manager so it can update the main model in DataExplorer 
    1975         GuiUtils.updateModelItemWithPlot(self._index, fitted_data, name) 
     2056        GuiUtils.updateModelItemWithPlot(self.all_data[self.data_index], fitted_data, name) 
    19762057 
    19772058    def createTheoryIndex(self, fitted_data): 
     
    20032084    def methodCompleteForData(self): 
    20042085        '''return the method for result parsin on calc complete ''' 
    2005         return self.complete1D if isinstance(self.data, Data1D) else self.complete2D 
    2006  
    2007     def calculateQGridForModel(self): 
    2008         """ 
    2009         Prepare the fitting data object, based on current ModelModel 
    2010         """ 
    2011         if self.kernel_module is None: 
    2012             return 
     2086        return self.completed1D if isinstance(self.data, Data1D) else self.completed2D 
     2087 
     2088    def calculateQGridForModelExt(self, data=None, model=None, completefn=None, use_threads=True): 
     2089        """ 
     2090        Wrapper for Calc1D/2D calls 
     2091        """ 
     2092        if data is None: 
     2093            data = self.data 
     2094        if model is None: 
     2095            model = self.kernel_module 
     2096        if completefn is None: 
     2097            completefn = self.methodCompleteForData() 
     2098 
    20132099        # Awful API to a backend method. 
    2014         method = self.methodCalculateForData()(data=self.data, 
    2015                                                model=self.kernel_module, 
     2100        calc_thread = self.methodCalculateForData()(data=data, 
     2101                                               model=model, 
    20162102                                               page_id=0, 
    20172103                                               qmin=self.q_range_min, 
     
    20222108                                               fid=None, 
    20232109                                               toggle_mode_on=False, 
    2024                                                completefn=None, 
     2110                                               completefn=completefn, 
    20252111                                               update_chisqr=True, 
    20262112                                               exception_handler=self.calcException, 
    20272113                                               source=None) 
    2028  
    2029         calc_thread = threads.deferToThread(method.compute) 
    2030         calc_thread.addCallback(self.methodCompleteForData()) 
    2031         calc_thread.addErrback(self.calculateDataFailed) 
     2114        if use_threads: 
     2115            if LocalConfig.USING_TWISTED: 
     2116                # start the thread with twisted 
     2117                thread = threads.deferToThread(calc_thread.compute) 
     2118                thread.addCallback(completefn) 
     2119                thread.addErrback(self.calculateDataFailed) 
     2120            else: 
     2121                # Use the old python threads + Queue 
     2122                calc_thread.queue() 
     2123                calc_thread.ready(2.5) 
     2124        else: 
     2125            results = calc_thread.compute() 
     2126            completefn(results) 
     2127 
     2128    def calculateQGridForModel(self): 
     2129        """ 
     2130        Prepare the fitting data object, based on current ModelModel 
     2131        """ 
     2132        if self.kernel_module is None: 
     2133            return 
     2134        self.calculateQGridForModelExt() 
    20322135 
    20332136    def calculateDataFailed(self, reason): 
     
    20362139        """ 
    20372140        print("Calculate Data failed with ", reason) 
     2141 
     2142    def completed1D(self, return_data): 
     2143        self.Calc1DFinishedSignal.emit(return_data) 
     2144 
     2145    def completed2D(self, return_data): 
     2146        self.Calc2DFinishedSignal.emit(return_data) 
    20382147 
    20392148    def complete1D(self, return_data): 
     
    20792188        residuals_plot.id = "Residual " + residuals_plot.id 
    20802189        self.createNewIndex(residuals_plot) 
    2081         #self.communicate.plotUpdateSignal.emit([residuals_plot]) 
    20822190 
    20832191    def calcException(self, etype, value, tb): 
     
    23862494    def setFittingStarted(self): 
    23872495        """ 
    2388         Set item enablement on fitting start 
    2389         """ 
    2390         #disable the Fit button 
    2391         self.cmdFit.setText('Running...') 
    2392         self.cmdFit.setEnabled(False) 
     2496        Set buttion caption on fitting start 
     2497        """ 
     2498        # Notify the user that fitting is being run 
     2499        # Allow for stopping the job 
     2500        self.cmdFit.setStyleSheet('QPushButton {color: red;}') 
     2501        self.cmdFit.setText('Stop fit') 
    23932502 
    23942503    def setFittingStopped(self): 
    23952504        """ 
    2396         Set item enablement on fitting stop 
    2397         """ 
    2398         #enable the Fit button 
     2505        Set button caption on fitting stop 
     2506        """ 
     2507        # Notify the user that fitting is available 
     2508        self.cmdFit.setStyleSheet('QPushButton {color: black;}') 
    23992509        self.cmdFit.setText("Fit") 
    2400         self.cmdFit.setEnabled(True) 
     2510        self.fit_started = False 
    24012511 
    24022512    def readFitPage(self, fp): 
  • src/sas/qtgui/Perspectives/Fitting/GPUOptions.py

    re90988c raed0532  
    170170        """ 
    171171        help_location = GuiUtils.HELP_DIRECTORY_LOCATION 
    172         help_location += "/user/sasgui/perspectives/fitting/gpu_setup.html" 
     172        help_location += "/user/qtgui/Perspectives/Fitting/gpu_setup.html" 
    173173        help_location += "#device-selection" 
    174174        # Display the page in default browser 
  • src/sas/qtgui/Perspectives/Fitting/ModelThread.py

    rcee5c78 rd4dac80  
    88from sas.sascalc.data_util.calcthread import CalcThread 
    99from sas.sascalc.fit.MultiplicationModel import MultiplicationModel 
     10import sas.qtgui.Utilities.LocalConfig as LocalConfig 
    1011 
    1112class Calc2D(CalcThread): 
     
    99100        output[index_model] = value 
    100101        elapsed = time.time() - self.starttime 
    101         #self.complete(image=output, 
    102         #               data=self.data, 
    103         #               page_id=self.page_id, 
    104         #               model=self.model, 
    105         #               state=self.state, 
    106         #               toggle_mode_on=self.toggle_mode_on, 
    107         #               elapsed=elapsed, 
    108         #               index=index_model, 
    109         #               fid=self.fid, 
    110         #               qmin=self.qmin, 
    111         #               qmax=self.qmax, 
    112         #               weight=self.weight, 
    113         #               #qstep=self.qstep, 
    114         #               update_chisqr=self.update_chisqr, 
    115         #               source=self.source) 
    116         return (output, 
    117                 self.data, 
    118                 self.page_id, 
    119                 self.model, 
    120                 self.state, 
    121                 self.toggle_mode_on, 
    122                 elapsed, 
    123                 index_model, 
    124                 self.fid, 
    125                 self.qmin, 
    126                 self.qmax, 
    127                 self.weight, 
    128                 self.update_chisqr, 
    129                 self.source) 
     102 
     103        if LocalConfig.USING_TWISTED: 
     104            return (output, 
     105                    self.data, 
     106                    self.page_id, 
     107                    self.model, 
     108                    self.state, 
     109                    self.toggle_mode_on, 
     110                    elapsed, 
     111                    index_model, 
     112                    self.fid, 
     113                    self.qmin, 
     114                    self.qmax, 
     115                    self.weight, 
     116                    self.update_chisqr, 
     117                    self.source) 
     118        else: 
     119            self.complete(image=output, 
     120                           data=self.data, 
     121                           page_id=self.page_id, 
     122                           model=self.model, 
     123                           state=self.state, 
     124                           toggle_mode_on=self.toggle_mode_on, 
     125                           elapsed=elapsed, 
     126                           index=index_model, 
     127                           fid=self.fid, 
     128                           qmin=self.qmin, 
     129                           qmax=self.qmax, 
     130                           weight=self.weight, 
     131                           #qstep=self.qstep, 
     132                           update_chisqr=self.update_chisqr, 
     133                           source=self.source) 
    130134 
    131135 
     
    229233        elapsed = time.time() - self.starttime 
    230234 
    231         return (self.data.x[index], output[index], 
    232                 self.page_id, 
    233                 self.state, 
    234                 self.weight, 
    235                 self.fid, 
    236                 self.toggle_mode_on, 
    237                 elapsed, index, self.model, 
    238                 self.data, 
    239                 self.update_chisqr, 
    240                 self.source) 
    241  
    242         # TODO: as of 4.1, the output contains more items: 
    243         # unsmeared_* and pq_model/sq_model 
    244         # Need to add these too 
    245  
    246         #self.complete(x=self.data.x[index], y=output[index], 
    247         #              page_id=self.page_id, 
    248         #              state=self.state, 
    249         #              weight=self.weight, 
    250         #              fid=self.fid, 
    251         #              toggle_mode_on=self.toggle_mode_on, 
    252         #              elapsed=elapsed, index=index, model=self.model, 
    253         #              data=self.data, 
    254         #              update_chisqr=self.update_chisqr, 
    255         #              source=self.source, 
    256         #              unsmeared_model=unsmeared_output, 
    257         #              unsmeared_data=unsmeared_data, 
    258         #              unsmeared_error=unsmeared_error, 
    259         #              pq_model=pq_values, 
    260         #              sq_model=sq_values) 
     235        if LocalConfig.USING_TWISTED: 
     236            return (self.data.x[index], output[index], 
     237                    self.page_id, 
     238                    self.state, 
     239                    self.weight, 
     240                    self.fid, 
     241                    self.toggle_mode_on, 
     242                    elapsed, index, self.model, 
     243                    self.data, 
     244                    self.update_chisqr, 
     245                    self.source) 
     246        else: 
     247            self.complete(x=self.data.x[index], y=output[index], 
     248                          page_id=self.page_id, 
     249                          state=self.state, 
     250                          weight=self.weight, 
     251                          fid=self.fid, 
     252                          toggle_mode_on=self.toggle_mode_on, 
     253                          elapsed=elapsed, index=index, model=self.model, 
     254                          data=self.data, 
     255                          update_chisqr=self.update_chisqr, 
     256                          source=self.source, 
     257                          unsmeared_model=unsmeared_output, 
     258                          unsmeared_data=unsmeared_data, 
     259                          unsmeared_error=unsmeared_error, 
     260                          pq_model=pq_values, 
     261                          sq_model=sq_values) 
    261262 
    262263    def results(self): 
  • src/sas/qtgui/Perspectives/Fitting/ModelUtilities.py

    r3b3b40b rd4dac80  
    173173        return {} 
    174174 
    175     plugin_log("looking for models in: %s" % str(directory)) 
    176     # compile_file(directory)  #always recompile the folder plugin 
    177     logging.info("plugin model dir: %s" % str(directory)) 
    178  
    179175    plugins = {} 
    180176    for filename in os.listdir(directory): 
  • src/sas/qtgui/Perspectives/Fitting/MultiConstraint.py

    r3b3b40b raed0532  
    142142        try: 
    143143            help_location = GuiUtils.HELP_DIRECTORY_LOCATION + \ 
    144             "/user/sasgui/perspectives/fitting/fitting_help.html#simultaneous-fits-with-constraints" 
     144            "/user/qtgui/Perspectives/Fitting/fitting_help.html#simultaneous-fits-with-constraints" 
    145145            webbrowser.open('file://' + os.path.realpath(help_location)) 
    146146        except AttributeError: 
  • src/sas/qtgui/Perspectives/Fitting/UI/FittingWidgetUI.ui

    r3b3b40b rd4dac80  
    216216            </property> 
    217217            <property name="toolTip"> 
    218              <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Switch on magnetic scattering parameters.&lt;/p&gt;&lt;p&gt;This option is available only for 2D models.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
     218             <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Switch on Chain Fitting (parameter reuse) for batch datasets.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
    219219            </property> 
    220220            <property name="text"> 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/ConstraintWidgetTest.py

    r3b3b40b r80468f6  
    3030            def communicator(self): 
    3131                return GuiUtils.Communicate() 
    32             def communicate(self): 
    33                 return GuiUtils.Communicate() 
     32            communicate = GuiUtils.Communicate() 
    3433 
    3534        '''Create the perspective''' 
    3635        self.perspective = FittingWindow(dummy_manager()) 
     36        ConstraintWidget.updateSignalsFromTab = MagicMock() 
    3737 
    3838        self.widget = ConstraintWidget(parent=self.perspective) 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingLogicTest.py

    r53c771e r80468f6  
    9898        data = Data1D(x=[1,2,3],y=[3,4,5]) 
    9999        data.name = "boop" 
     100        data.id = "poop" 
    100101        return_data = (data.x,data.y, 7, None, None, 
    101102                        0, True, 0.0, 1, data, 
     
    107108        self.assertFalse(new_plot.is_data) 
    108109        self.assertEqual(new_plot.dy.size, 3) 
    109         self.assertEqual(new_plot.title, "boop [boop]") 
    110         self.assertEqual(new_plot.name, "boop [boop]") 
     110        self.assertEqual(new_plot.title, "boop [poop]") 
     111        self.assertEqual(new_plot.name, "boop [poop]") 
    111112 
    112113    def testNew2DPlot(self): 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingPerspectiveTest.py

    r63319b0 r80468f6  
    2727            def communicator(self): 
    2828                return GuiUtils.Communicate() 
    29             def communicate(self): 
    30                 return GuiUtils.Communicate() 
     29            communicate = GuiUtils.Communicate() 
    3130 
    3231        '''Create the perspective''' 
     
    4544        self.assertEqual(len(self.widget.tabs), 1) 
    4645        self.assertEqual(self.widget.maxIndex, 1) 
    47         self.assertEqual(self.widget.maxCSIndex, 0) 
    4846        self.assertEqual(self.widget.getTabName(), "FitPage1") 
    4947 
     
    6664        self.widget.addConstraintTab() 
    6765        self.assertEqual(len(self.widget.tabs), 2) 
    68         self.assertEqual(self.widget.getCSTabName(), "Const. & Simul. Fit1") 
    69         self.assertEqual(self.widget.maxCSIndex, 1) 
     66        self.assertEqual(self.widget.getCSTabName(), "Const. & Simul. Fit") 
    7067 
    7168    def testResetTab(self): 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py

    r14ec91c5 r80468f6  
    181181 
    182182        # Observe no such luck 
    183         self.assertEqual(self.widget.cbCategory.currentIndex(), 6) 
     183        self.assertEqual(self.widget.cbCategory.currentIndex(), 7) 
    184184        self.assertEqual(self.widget.cbModel.count(), 29) 
    185185 
     
    737737 
    738738            # the fit button changed caption and got disabled 
    739             self.assertEqual(self.widget.cmdFit.text(), 'Running...') 
     739            self.assertEqual(self.widget.cmdFit.text(), 'Stop fit') 
    740740            self.assertFalse(self.widget.cmdFit.isEnabled()) 
    741741 
     
    781781 
    782782            # the fit button changed caption and got disabled 
    783             self.assertEqual(self.widget.cmdFit.text(), 'Running...') 
     783            self.assertEqual(self.widget.cmdFit.text(), 'Stop fit') 
    784784            self.assertFalse(self.widget.cmdFit.isEnabled()) 
    785785 
     
    12051205        # Assure the row has the constraint 
    12061206        self.assertEqual(self.widget.getConstraintForRow(row), const) 
    1207         # but not complex constraint! 
    1208         self.assertFalse(self.widget.rowHasConstraint(row)) 
     1207        self.assertTrue(self.widget.rowHasConstraint(row)) 
    12091208 
    12101209        # assign complex constraint now 
     
    12581257        self.assertEqual(spy.called()[1]['args'][0], [row2]) 
    12591258 
    1260         # Other properties 
    1261         self.assertEqual(self.widget.getConstraintsForModel(), [('background', '0.001'), ('radius', '20')]) 
    1262  
    12631259    def testDeleteConstraintOnParameter(self): 
    12641260        """ 
     
    12941290 
    12951291        # see that the other constraint is still present 
    1296         self.assertEqual(self.widget.getConstraintsForModel(), [('radius', '20')]) 
     1292        cons = self.widget.getConstraintForRow(4) # 4 = radius 
     1293        self.assertEqual(cons.param, "radius") 
     1294        self.assertEqual(cons.value, "20") 
    12971295 
    12981296        # kill the other constraint 
     
    13001298 
    13011299        # see that the other constraint is still present 
    1302         self.assertEqual(self.widget.getConstraintsForModel(), []) 
     1300        self.assertEqual(self.widget.getConstraintsForModel(), [('radius', None)]) 
    13031301 
    13041302    def testGetConstraintForRow(self): 
     
    14001398 
    14011399        # simple constraints 
    1402         self.assertEqual(self.widget.getConstraintsForModel(), [('background', '0.001'), ('radius', '20')]) 
     1400        # self.assertEqual(self.widget.getConstraintsForModel(), [('background', '0.001'), ('radius', '20')]) 
     1401        cons = self.widget.getConstraintForRow(1) # 1 - background 
     1402        self.assertEqual(cons.param, "background") 
     1403        self.assertEqual(cons.value, "0.001") 
     1404        cons = self.widget.getConstraintForRow(4) # 4 = radius 
     1405        self.assertEqual(cons.param, "radius") 
     1406        self.assertEqual(cons.value, "20") 
     1407 
    14031408        objects = self.widget.getConstraintObjectsForModel() 
    14041409        self.assertEqual(len(objects), 2) 
     
    14061411        self.assertEqual(objects[0].param, 'background') 
    14071412 
    1408  
    14091413        # add complex constraint 
    14101414        const = Constraint(parent=None, param='scale', func='5*sld') 
    14111415        row = 0 
    14121416        self.widget.addConstraintToRow(constraint=const, row=row) 
    1413         self.assertEqual(self.widget.getConstraintsForModel(),[('scale', '5*sld'), ('background', '0.001'), ('radius', '20')]) 
     1417        #self.assertEqual(self.widget.getConstraintsForModel(),[('scale', '5*sld'), ('background', '0.001'), ('radius', None)]) 
     1418        cons = self.widget.getConstraintForRow(4) # 4 = radius 
     1419        self.assertEqual(cons.param, "radius") 
     1420        self.assertEqual(cons.value, "20") 
     1421 
    14141422        objects = self.widget.getConstraintObjectsForModel() 
    14151423        self.assertEqual(len(objects), 3) 
  • src/sas/qtgui/Perspectives/Fitting/media/ball.ico

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/batch_button_area.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/cat_fig0.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/cat_fig1.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/cat_fig2.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/combine_batch_grid.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/combine_batch_page.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/combine_batch_plot.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/edit_menu.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/edit_model_menu.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/file_menu.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/fitting.rst

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/fitting_help.rst

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/new_model.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/plot_button.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/residuals_help.rst

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/restore_batch_window.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/sum_model.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/view_button.png

    • Property mode changed from 100644 to 100755
  • src/sas/qtgui/Perspectives/Fitting/media/view_data_model.png

    • Property mode changed from 100644 to 100755
Note: See TracChangeset for help on using the changeset viewer.