Changeset 6dbff18 in sasview for src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
- Timestamp:
- Sep 3, 2018 10:14:52 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 79bd268
- Parents:
- 8274471e
- git-author:
- Piotr Rozyczko <rozyczko@…> (09/03/18 10:13:50)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (09/03/18 10:14:52)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
reef298d4 r6dbff18 226 226 self.models = {} 227 227 # Parameters to fit 228 self.parameters_to_fit = None 228 self.main_params_to_fit = [] 229 self.poly_params_to_fit = [] 230 self.magnet_params_to_fit = [] 231 229 232 # Fit options 230 233 self.q_range_min = 0.005 … … 956 959 957 960 # Reset parameters to fit 958 self. parameters_to_fit = None961 self.resetParametersToFit() 959 962 self.has_error_column = False 960 963 self.has_poly_error_column = False … … 980 983 981 984 # Reset parameters to fit 982 self. parameters_to_fit = None985 self.resetParametersToFit() 983 986 self.has_error_column = False 984 987 self.has_poly_error_column = False 985 988 986 989 self.respondToModelStructure(model=model, structure_factor=structure) 990 991 def resetParametersToFit(self): 992 """ 993 Clears the list of parameters to be fitted 994 """ 995 self.main_params_to_fit = [] 996 self.poly_params_to_fit = [] 997 self.magnet_params_to_fit = [] 987 998 988 999 def onCustomModelChange(self): … … 1132 1143 parameter_name = parameter_name + '.width' 1133 1144 if value == QtCore.Qt.Checked: 1134 self.p arameters_to_fit.append(parameter_name)1145 self.poly_params_to_fit.append(parameter_name) 1135 1146 else: 1136 if parameter_name in self.p arameters_to_fit:1137 self.p arameters_to_fit.remove(parameter_name)1138 self.cmdFit.setEnabled(self. parameters_to_fit != [] and self.logic.data_is_loaded)1147 if parameter_name in self.poly_params_to_fit: 1148 self.poly_params_to_fit.remove(parameter_name) 1149 self.cmdFit.setEnabled(self.haveParamsToFit()) 1139 1150 1140 1151 elif model_column in [delegate.poly_min, delegate.poly_max]: … … 1188 1199 value = item.checkState() 1189 1200 if value == QtCore.Qt.Checked: 1190 self. parameters_to_fit.append(parameter_name)1201 self.magnet_params_to_fit.append(parameter_name) 1191 1202 else: 1192 if parameter_name in self. parameters_to_fit:1193 self. parameters_to_fit.remove(parameter_name)1194 self.cmdFit.setEnabled(self. parameters_to_fit != [] and self.logic.data_is_loaded)1203 if parameter_name in self.magnet_params_to_fit: 1204 self.magnet_params_to_fit.remove(parameter_name) 1205 self.cmdFit.setEnabled(self.haveParamsToFit()) 1195 1206 # Update state stack 1196 1207 self.updateUndo() … … 1477 1488 qmin = self.q_range_min 1478 1489 qmax = self.q_range_max 1479 params_to_fit = self.parameters_to_fit 1490 1491 params_to_fit = self.main_params_to_fit 1492 if self.chkPolydispersity.isChecked(): 1493 params_to_fit += self.poly_params_to_fit 1494 if self.chkMagnetism.isChecked(): 1495 params_to_fit += self.magnet_params_to_fit 1480 1496 if not params_to_fit: 1481 1497 raise ValueError('Fitting requires at least one parameter to optimize.') … … 2046 2062 self._last_model_row = self._model_model.rowCount() 2047 2063 2064 def haveParamsToFit(self): 2065 """ 2066 Finds out if there are any parameters ready to be fitted 2067 """ 2068 return (self.main_params_to_fit!=[] 2069 or self.poly_params_to_fit!=[] 2070 or self.magnet_params_to_fit != []) and \ 2071 self.logic.data_is_loaded 2072 2048 2073 def onMainParamsChange(self, item): 2049 2074 """ … … 2054 2079 if model_column == 0: 2055 2080 self.checkboxSelected(item) 2056 self.cmdFit.setEnabled(self. parameters_to_fit != [] and self.logic.data_is_loaded)2081 self.cmdFit.setEnabled(self.haveParamsToFit()) 2057 2082 # Update state stack 2058 2083 self.updateUndo() … … 2113 2138 # Convert to proper indices and set requested enablement 2114 2139 self.setParameterSelection(status) 2115 #[self._model_model.item(row, 0).setCheckState(status) for row in self.selectedParameters()]2116 2140 self._model_model.blockSignals(False) 2117 2141 2118 2142 # update the list of parameters to fit 2119 main_params = self.checkedListFromModel(self._model_model) 2120 poly_params = self.checkedListFromModel(self._poly_model) 2121 magnet_params = self.checkedListFromModel(self._magnet_model) 2122 2123 # Retrieve poly params names 2124 poly_params = [param.rsplit()[-1] + '.width' for param in poly_params] 2125 2126 self.parameters_to_fit = main_params + poly_params + magnet_params 2143 self.main_params_to_fit = self.checkedListFromModel(self._model_model) 2127 2144 2128 2145 def checkedListFromModel(self, model): … … 2752 2769 2753 2770 fp.chi2 = self.chi2 2754 fp.parameters_to_fit = self.parameters_to_fit 2771 fp.main_params_to_fit = self.main_params_to_fit 2772 fp.poly_params_to_fit = self.poly_params_to_fit 2773 fp.magnet_params_to_fit = self.magnet_params_to_fit 2755 2774 fp.kernel_module = self.kernel_module 2756 2775
Note: See TracChangeset
for help on using the changeset viewer.