Changeset 30bed93 in sasview for src/sas/qtgui/Perspectives/Fitting
- Timestamp:
- Sep 21, 2018 5:41:31 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- c928e81
- Parents:
- 33d5956 (diff), d8d81ea (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. - git-author:
- Ingo Breßler <dev@…> (09/21/18 05:41:31)
- git-committer:
- GitHub <noreply@…> (09/21/18 05:41:31)
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
r8faac15 r30bed93 570 570 return residuals 571 571 572 def plotPolydispersities(model): 573 plots = [] 574 if model is None: 575 return plots 576 # test for model being a sasmodels.sasview_model.SasviewModel? 577 for name in model.dispersion.keys(): 578 xarr, yarr = model.get_weights(name) 579 if len(xarr) <= 1: # param name not found or no polydisp. 580 continue 581 # create Data1D as in residualsData1D() and fill x/y members 582 # similar to FittingLogic._create1DPlot() but different data/axes 583 data1d = Data1D(x=xarr, y=yarr) 584 xunit = model.details[name][0] 585 data1d.xaxis(r'\rm{{{}}}'.format(name.replace('_', '\_')), xunit) 586 data1d.yaxis(r'\rm{weight}', 'normalized') 587 data1d.scale = 'linear' 588 data1d.symbol = 'Line' 589 data1d.name = "{} polydispersity".format(name) 590 data1d.id = data1d.name # placeholder, has to be completed later 591 data1d.plot_role = Data1D.ROLE_RESIDUAL 592 plots.append(data1d) 593 return plots 594 572 595 def binary_encode(i, digits): 573 596 return [i >> d & 1 for d in range(digits)] -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r33d5956 r30bed93 58 58 DEFAULT_POLYDISP_FUNCTION = 'gaussian' 59 59 60 # CRUFT: remove when new release of sasmodels is available 61 # https://github.com/SasView/sasview/pull/181#discussion_r218135162 62 from sasmodels.sasview_model import SasviewModel 63 if not hasattr(SasviewModel, 'get_weights'): 64 def get_weights(self, name): 65 """ 66 Returns the polydispersity distribution for parameter *name* as *value* and *weight* arrays. 67 """ 68 # type: (str) -> Tuple(np.ndarray, np.ndarray) 69 _, x, w = self._get_weights(self._model_info.parameters[name]) 70 return x, w 71 72 SasviewModel.get_weights = get_weights 60 73 61 74 logger = logging.getLogger(__name__) … … 2488 2501 2489 2502 if self.data_is_loaded: 2490 # delete any plots associated with the data that were not updated (e.g. to remove beta(Q), S_eff(Q)) 2503 # delete any plots associated with the data that were not updated 2504 # (e.g. to remove beta(Q), S_eff(Q)) 2491 2505 GuiUtils.deleteRedundantPlots(self.all_data[self.data_index], new_plots) 2492 2506 pass 2493 2507 else: 2494 # delete theory items for the model, in order to get rid of any redundant items, e.g. beta(Q), S_eff(Q) 2508 # delete theory items for the model, in order to get rid of any 2509 # redundant items, e.g. beta(Q), S_eff(Q) 2495 2510 self.communicate.deleteIntermediateTheoryPlotsSignal.emit(self.kernel_module.id) 2511 2512 # Create plots for parameters with enabled polydispersity 2513 for plot in FittingUtilities.plotPolydispersities(return_data.get('model', None)): 2514 data_id = fitted_data.id.split() 2515 plot.id = "{} [{}] {}".format(data_id[0], plot.name, " ".join(data_id[1:])) 2516 data_name = fitted_data.name.split() 2517 plot.name = " ".join([data_name[0], plot.name] + data_name[1:]) 2518 self.createNewIndex(plot) 2519 new_plots.append(plot) 2496 2520 2497 2521 # Create plots for intermediate product data -
src/sas/qtgui/Perspectives/Fitting/FittingOptions.py
rff3b293 r8873ab7 64 64 default_index = self.cbAlgorithm.findText(default_name) 65 65 self.cbAlgorithm.setCurrentIndex(default_index) 66 # previous algorithm choice 67 self.previous_index = default_index 66 68 67 69 # Assign appropriate validators … … 121 123 122 124 # Convert the name into widget instance 123 widget_to_activate = eval(widget_name) 125 try: 126 widget_to_activate = eval(widget_name) 127 except AttributeError: 128 # We don't yet have this optimizer. 129 # Show message 130 msg = "This algorithm has not yet been implemented in SasView.\n" 131 msg += "Please choose a different algorithm" 132 QtWidgets.QMessageBox.warning(self, 133 'Warning', 134 msg, 135 QtWidgets.QMessageBox.Ok) 136 # Move the index to previous position 137 self.cbAlgorithm.setCurrentIndex(self.previous_index) 138 return 139 124 140 index_for_this_id = self.stackedWidget.indexOf(widget_to_activate) 125 141 … … 133 149 # OK has to be reinitialized to True 134 150 self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 151 152 # keep reference 153 self.previous_index = index 135 154 136 155 def onApply(self): … … 143 162 # e.g. 'samples' for 'dream' is 'self.samples_dream' 144 163 widget_name = 'self.'+option+'_'+self.current_fitter_id 145 line_edit = eval(widget_name) 164 try: 165 line_edit = eval(widget_name) 166 except AttributeError: 167 # Skip bumps monitors 168 continue 146 169 if line_edit is None or not isinstance(line_edit, QtWidgets.QLineEdit): 147 170 continue … … 165 188 return 166 189 try: 167 new_value = widget.currentText() if isinstance(widget, QtWidgets.QComboBox) \ 168 else float(widget.text()) 190 if isinstance(widget, QtWidgets.QComboBox): 191 new_value = widget.currentText() 192 else: 193 try: 194 new_value = int(widget.text()) 195 except ValueError: 196 new_value = float(widget.text()) 197 #new_value = widget.currentText() if isinstance(widget, QtWidgets.QComboBox) \ 198 # else float(widget.text()) 169 199 self.config.values[self.current_fitter_id][option] = new_value 170 200 except ValueError: -
src/sas/qtgui/Perspectives/Fitting/UI/ComplexConstraintUI.ui
r305114c r1738173 7 7 <x>0</x> 8 8 <y>0</y> 9 <width> 463</width>10 <height> 234</height>9 <width>367</width> 10 <height>199</height> 11 11 </rect> 12 12 </property> … … 135 135 <widget class="QLabel" name="lblWarning"> 136 136 <property name="text"> 137 <string><html><head/><body><p><span style=" color:#ff0000;">Warning! Polydisperse parameter selected.<br/></span>Constraints involving polydisperse parameters only apply to<br/>starting values and are no r re-applied during size or angle polydispersity<br/>integrations. To do whichrequires creating a custom model.</p></body></html></string>137 <string><html><head/><body><p><span style=" color:#ff0000;">Warning! Polydisperse parameter selected.<br/></span>Constraints involving polydisperse parameters only apply to<br/>starting values and are not re-applied during size or angle polydispersity<br/>integrations. To do so requires creating a custom model.</p></body></html></string> 138 138 </property> 139 139 </widget> -
src/sas/qtgui/Perspectives/Fitting/UI/FittingWidgetUI.ui
ra2e8ea5 rfc5d2d7f 7 7 <x>0</x> 8 8 <y>0</y> 9 <width> 566</width>9 <width>651</width> 10 10 <height>646</height> 11 11 </rect> -
src/sas/qtgui/Perspectives/Fitting/UI/MultiConstraintUI.ui
raa88b76 r1738173 10 10 <x>0</x> 11 11 <y>0</y> 12 <width> 436</width>13 <height>2 17</height>12 <width>369</width> 13 <height>201</height> 14 14 </rect> 15 15 </property> … … 121 121 <widget class="QLabel" name="lblWarning"> 122 122 <property name="text"> 123 <string><html><head/><body><p><span style=" color:#ff0000;">Warning! Polydisperse parameter selected.<br/></span>Constraints involving polydisperse parameters only apply to<br/>starting values and are no r re-applied during size or angle polydispersity<br/>integrations. To do whichrequires creating a custom model.</p></body></html></string>123 <string><html><head/><body><p><span style=" color:#ff0000;">Warning! Polydisperse parameter selected.<br/></span>Constraints involving polydisperse parameters only apply to<br/>starting values and are not re-applied during size or angle polydispersity<br/>integrations. To do so requires creating a custom model.</p></body></html></string> 124 124 </property> 125 125 </widget> -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
r1a15ada r8faac15 397 397 header_tooltips = ['Select parameter for fitting', 398 398 'Enter polydispersity ratio (Std deviation/mean).\n'+ 399 'For angles this can be either std deviation or full width (for uniform distributions) in degrees', 400 'STD: standard deviation from the mean value', 399 'For angles this can be either std deviation or half width (for uniform distributions) in degrees', 401 400 'Enter minimum value for parameter', 402 401 'Enter maximum value for parameter', … … 620 619 # Set to 0 621 620 self.widget.lstParams.indexWidget(func_index).setCurrentIndex(0) 622 self.assertEqual(self.widget._model_model.rowCount(), last_row - 2) # 2 fewer rows than default621 self.assertEqual(self.widget._model_model.rowCount(), last_row - 2) 623 622 624 623 def testPlotTheory(self): … … 658 657 self.assertEqual(spy.count(), 0) 659 658 660 def testPlotData(self):659 def notestPlotData(self): 661 660 """ 662 661 See that data item can produce a chart
Note: See TracChangeset
for help on using the changeset viewer.