Ignore:
Timestamp:
Apr 6, 2017 3:33:44 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:
2155824
Parents:
f182f93
Message:

Allow for multiple datasets to be opened by the fitting perspective

File:
1 edited

Legend:

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

    rf182f93 r454670d  
    44import numpy 
    55from collections import defaultdict 
     6from itertools import izip 
    67 
    78import logging 
     
    133134        self.cbCategory.setCurrentIndex(0) 
    134135 
     136        # Connect signals to controls 
     137        self.initializeSignals() 
     138 
     139        # Initial control state 
     140        self.initializeControls() 
     141 
    135142        self._index = None 
    136143        if data is not None: 
    137144            self.data = data 
    138  
    139         # Connect signals to controls 
    140         self.initializeSignals() 
    141  
    142         # Initial control state 
    143         self.initializeControls() 
     145        # Update Q Ranges 
     146        #self.updateQRange() 
    144147 
    145148    @property 
     
    150153    def data(self, value): 
    151154        """ data setter """ 
    152         assert isinstance(value[0], QtGui.QStandardItem) 
     155        assert isinstance(value, QtGui.QStandardItem) 
    153156        # _index contains the QIndex with data 
    154         self._index = value[0] 
     157        self._index = value 
    155158 
    156159        # Update logics with data items 
    157         self.logic.data = GuiUtils.dataFromItem(value[0]) 
     160        self.logic.data = GuiUtils.dataFromItem(value) 
    158161 
    159162        self.data_is_loaded = True 
     
    163166        self.updateQRange() 
    164167        self.cmdFit.setEnabled(True) 
     168        print "set to ", self.cmdFit.isEnabled() 
    165169 
    166170    def acceptsData(self): 
     
    189193 
    190194    def togglePoly(self, isChecked): 
    191         """ 
    192         Enable/disable the polydispersity tab 
    193         """ 
     195        """ Enable/disable the polydispersity tab """ 
    194196        self.tabFitting.setTabEnabled(TAB_POLY, isChecked) 
    195197 
    196198    def toggleMagnetism(self, isChecked): 
    197         """ 
    198         Enable/disable the magnetism tab 
    199         """ 
     199        """ Enable/disable the magnetism tab """ 
    200200        self.tabFitting.setTabEnabled(TAB_MAGNETISM, isChecked) 
    201201 
    202202    def toggle2D(self, isChecked): 
    203         """ 
    204         Enable/disable the controls dependent on 1D/2D data instance 
    205         """ 
     203        """ Enable/disable the controls dependent on 1D/2D data instance """ 
    206204        self.chkMagnetism.setEnabled(isChecked) 
    207205        self.is2D = isChecked 
     
    223221        self.tabFitting.setTabEnabled(TAB_MAGNETISM, False) 
    224222        self.lblChi2Value.setText("---") 
    225         # Update Q Ranges 
    226         self.updateQRange() 
    227223 
    228224    def initializeSignals(self): 
     
    413409        """ 
    414410        Receive and display fitting results 
    415  
    416411        "result" is a tuple of actual result list and the fit time in seconds 
    417412        """ 
     
    426421            not numpy.all(numpy.isfinite(res.pvec)): 
    427422            msg = "Fitting did not converge!!!" 
     423            self.communicate.statusBarUpdateSignal.emit(msg) 
    428424            logging.error(msg) 
    429425            return 
     
    431427        elapsed = result[1] 
    432428        msg = "Fitting completed successfully in: %s s.\n" % GuiUtils.formatNumber(elapsed) 
    433  
    434429        self.communicate.statusBarUpdateSignal.emit(msg) 
    435430 
     
    438433        param_values = res.pvec 
    439434        param_stderr = res.stderr 
    440         from itertools import izip 
    441         # TODO: add errors to the dict so they can propagate to the view 
    442435        params_and_errors = zip(param_values, param_stderr) 
    443436        param_dict = dict(izip(param_list, params_and_errors)) 
     
    451444        self.lblChi2Value.setText(chi2_repr) 
    452445 
    453         pass 
     446        # Generate charts 
    454447 
    455448    def iterateOverModel(self, func): 
     
    475468                return 
    476469            # modify the param value 
    477             self._model_model.item(row_i, 1).setText(str(param_dict[param_name][0])) 
     470            param_repr = GuiUtils.formatNumber(param_dict[param_name][0], high=True) 
     471            self._model_model.item(row_i, 1).setText(param_repr) 
    478472            if self.has_error_column: 
    479                 self._model_model.item(row_i, 2).setText(str(param_dict[param_name][1])) 
     473                error_repr = GuiUtils.formatNumber(param_dict[param_name][1], high=True) 
     474                self._model_model.item(row_i, 2).setText(error_repr) 
    480475 
    481476        def createColumn(row_i): 
     
    500495        self._model_model.insertColumn(2, error_column) 
    501496        FittingUtilities.addErrorHeadersToModel(self._model_model) 
    502  
    503497 
    504498    def onPlot(self): 
     
    674668            structure_parameters = modelinfo.make_parameter_table(getattr(structure_module, 'parameters', [])) 
    675669            FittingUtilities.addSimpleParametersToModel(structure_parameters, self._model_model) 
    676             # Set the error column width to 0 
    677             self.lstParams.setColumnWidth(2, 20) 
    678670            # Update the counter used for multishell display 
    679671            self._last_model_row = self._model_model.rowCount() 
Note: See TracChangeset for help on using the changeset viewer.