Changeset 235d766 in sasview for src/sas


Ignore:
Timestamp:
Feb 8, 2018 8:37:28 AM (5 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:
731efec
Parents:
725d9c06
git-author:
Piotr Rozyczko <rozyczko@…> (02/08/18 08:32:10)
git-committer:
Piotr Rozyczko <rozyczko@…> (02/08/18 08:37:28)
Message:

Simple vs. complex constraints behaviour fixed.

Location:
src/sas/qtgui
Files:
4 edited

Legend:

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

    ra90c9c5 r235d766  
    294294        self.parent.fittingStoppedSignal.emit(self.getTabsForFit()) 
    295295 
     296        # Assure the fitting succeeded 
     297        if result is None or not result: 
     298            msg = "Fitting failed. Please ensure correctness of chosen constraints." 
     299            self.parent.communicate.statusBarUpdateSignal.emit(msg) 
     300            return 
     301 
    296302        # get the elapsed time 
    297303        elapsed = result[1] 
     
    553559 
    554560        # Check if any constraints present in tab 
    555         constraint_names = fit_page.getConstraintsForModel() 
     561        constraint_names = fit_page.getComplexConstraintsForModel() 
    556562        constraints = fit_page.getConstraintObjectsForModel() 
    557563        if not constraints:  
  • src/sas/qtgui/Perspectives/Fitting/FitThread.py

    • Property mode changed from 100755 to 100644
    rb3e8629 r235d766  
    9595            # print "ERROR IN FIT THREAD: ", traceback.format_exc() 
    9696            if self.handler is not None: 
    97                 self.handler.error(msg=traceback.format_exc()) 
     97                self.handler.error(msg=str(ex)) 
     98                self.completefn(None) 
     99            else: 
     100                return(None) 
    98101 
    99102 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r14ec91c5 r235d766  
    2424import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    2525import sas.qtgui.Utilities.LocalConfig as LocalConfig 
    26  
     26from sas.qtgui.Utilities.GridPanel import  BatchOutputPanel 
    2727from sas.qtgui.Utilities.CategoryInstaller import CategoryInstaller 
    2828from sas.qtgui.Plotting.PlotterData import Data1D 
     
    657657            param = self._model_model.item(row, 0).text() 
    658658            value = self._model_model.item(row, 1).text() 
    659             min = self._model_model.item(row, min_col).text() 
    660             max = self._model_model.item(row, max_col).text() 
     659            min_t = self._model_model.item(row, min_col).text() 
     660            max_t = self._model_model.item(row, max_col).text() 
    661661            # Create a Constraint object 
    662             constraint = Constraint(param=param, value=value, min=min, max=max, func=value) 
     662            constraint = Constraint(param=param, value=value, min=min_t, max=max_t) 
    663663            # Create a new item and add the Constraint object as a child 
    664664            item = QtGui.QStandardItem() 
    665665            item.setData(constraint) 
    666666            self._model_model.item(row, 1).setChild(0, item) 
     667            # Assumed correctness from the validator 
     668            value = float(value) 
     669            # BUMPS calculates log(max-min) without any checks, so let's assign minor range 
     670            min_v = value - (value/10000.0) 
     671            max_v = value + (value/10000.0) 
    667672            # Set min/max to the value constrained 
    668             self._model_model.item(row, min_col).setText(value) 
    669             self._model_model.item(row, max_col).setText(value) 
     673            self._model_model.item(row, min_col).setText(str(min_v)) 
     674            self._model_model.item(row, max_col).setText(str(max_v)) 
    670675            self.constraintAddedSignal.emit([row]) 
    671676            # Show visual hints for the constraint 
     
    735740        if item.hasChildren(): 
    736741            c = item.child(0).data() 
    737             if isinstance(c, Constraint) and c.func: 
     742            if isinstance(c, Constraint): 
    738743                return True 
    739744        return False 
     
    742747        """ 
    743748        Finds out if row of the main model has an active constraint child 
     749        """ 
     750        item = self._model_model.item(row,1) 
     751        if item.hasChildren(): 
     752            c = item.child(0).data() 
     753            if isinstance(c, Constraint) and c.active: 
     754                return True 
     755        return False 
     756 
     757    def rowHasActiveComplexConstraint(self, row): 
     758        """ 
     759        Finds out if row of the main model has an active, nontrivial constraint child 
    744760        """ 
    745761        item = self._model_model.item(row,1) 
     
    786802        model_name = self.kernel_module.name 
    787803        param_number = self._model_model.rowCount() 
    788         def preamble(s): 
    789             func = self._model_model.item(s, 1).child(0).data().func 
    790             value = self._model_model.item(s, 1).child(0).data().value 
    791             if func == value: 
    792                 return "" 
    793  
    794             return model_name + "." 
    795804        params = [(self._model_model.item(s, 0).text(), 
    796                     #preamble(s) +self._model_model.item(s, 1).child(0).data().func) 
    797805                    self._model_model.item(s, 1).child(0).data().func) 
    798806                    for s in range(param_number) if self.rowHasActiveConstraint(s)] 
     807        return params 
     808 
     809    def getComplexConstraintsForModel(self): 
     810        """ 
     811        Return a list of tuples. Each tuple contains constraints mapped as 
     812        ('constrained parameter', 'function to constrain') 
     813        e.g. [('sld','5*sld_solvent')]. 
     814        Only for constraints with defined VALUE 
     815        """ 
     816        model_name = self.kernel_module.name 
     817        param_number = self._model_model.rowCount() 
     818        params = [(self._model_model.item(s, 0).text(), 
     819                    self._model_model.item(s, 1).child(0).data().func) 
     820                    for s in range(param_number) if self.rowHasActiveComplexConstraint(s)] 
    799821        return params 
    800822 
     
    11471169        self.setFittingStopped() 
    11481170 
    1149         print ("BATCH FITTING FINISHED") 
    1150         # Add the Qt version of wx.aui.AuiNotebook and populate it 
    1151         pass 
     1171        # Show the grid panel 
     1172        grid_window = BatchOutputPanel(parent=self, output_data=result[0]) 
     1173        grid_window.show() 
    11521174 
    11531175    def fitComplete(self, result): 
     
    12221244        smearing, accuracy, smearing_min, smearing_max = self.smearing_widget.state() 
    12231245 
    1224         constraints = self.getConstraintsForModel() 
     1246        constraints = self.getComplexConstraintsForModel() 
    12251247        smearer = None 
    12261248        handler = None 
  • src/sas/qtgui/Utilities/LocalConfig.py

    r14ec91c5 r235d766  
    133133 
    134134# Default threading model 
    135 USING_TWISTED = True 
     135USING_TWISTED = False 
    136136 
    137137# Time out for updating sasview 
Note: See TracChangeset for help on using the changeset viewer.