Changeset b0b09b9 in sasview for src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
- Timestamp:
- Oct 26, 2017 3:13:05 AM (7 years ago)
- 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:
- 895e7359
- Parents:
- def64a0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
- Property mode changed from 100644 to 100755
rdef64a0 rb0b09b9 2 2 import os 3 3 from collections import defaultdict 4 from itertools import izip 4 5 5 6 6 import logging … … 69 69 if role == QtCore.Qt.ToolTipRole: 70 70 if orientation == QtCore.Qt.Horizontal: 71 return QtCore.QString(str(self.header_tooltips[section]))71 return str(self.header_tooltips[section]) 72 72 73 73 return QtGui.QStandardItemModel.headerData(self, section, orientation, role) … … 353 353 # Similarly on other tabs 354 354 self.options_widget.setEnablementOnDataLoad() 355 355 self.onSelectModel() 356 356 # Smearing tab 357 357 self.smearing_widget.updateSmearing(self.data) … … 473 473 model = str(self.cbModel.currentText()) 474 474 475 # empty combobox forced to be read 476 if not model: 477 return 475 478 # Reset structure factor 476 479 self.cbStructureFactor.setCurrentIndex(0) … … 763 766 """ 764 767 """ 765 print "UPDATE FIT"768 print("UPDATE FIT") 766 769 pass 767 770 … … 769 772 """ 770 773 """ 771 print "FIT FAILED: ", reason774 print("FIT FAILED: ", reason) 772 775 pass 773 776 … … 814 817 param_values = res.pvec # array([ 0.36221662, 0.0146783 ]) 815 818 param_stderr = res.stderr # array([ 1.71293015, 1.71294233]) 816 params_and_errors = zip(param_values, param_stderr)817 param_dict = dict( izip(param_list, params_and_errors))819 params_and_errors = list(zip(param_values, param_stderr)) 820 param_dict = dict(zip(param_list, params_and_errors)) 818 821 819 822 # Dictionary of fitted parameter: value, error … … 836 839 Take func and throw it inside the model row loop 837 840 """ 838 for row_i in xrange(self._model_model.rowCount()):841 for row_i in range(self._model_model.rowCount()): 839 842 func(row_i) 840 843 … … 851 854 # internal so can use closure for param_dict 852 855 param_name = str(self._model_model.item(row, 0).text()) 853 if param_name not in param_dict.keys():856 if param_name not in list(param_dict.keys()): 854 857 return 855 858 # modify the param value … … 863 866 # Utility function for updateof polydispersity part of the main model 864 867 param_name = str(self._model_model.item(row, 0).text())+'.width' 865 if param_name not in param_dict.keys():868 if param_name not in list(param_dict.keys()): 866 869 return 867 870 # modify the param value … … 878 881 return str(self._model_model.item(row, 0).text()) 879 882 880 [createItem(param_name) for param_name in param_dict.keys() if curr_param() == param_name]883 [createItem(param_name) for param_name in list(param_dict.keys()) if curr_param() == param_name] 881 884 882 885 error_column.append(item) … … 922 925 Take func and throw it inside the poly model row loop 923 926 """ 924 for row_i in xrange(self._poly_model.rowCount()):927 for row_i in range(self._poly_model.rowCount()): 925 928 func(row_i) 926 929 … … 931 934 return 932 935 param_name = str(self._poly_model.item(row_i, 0).text()).rsplit()[-1] + '.width' 933 if param_name not in param_dict.keys():936 if param_name not in list(param_dict.keys()): 934 937 return 935 938 # modify the param value … … 954 957 return str(self._poly_model.item(row_i, 0).text()).rsplit()[-1] + '.width' 955 958 956 [createItem(param_name) for param_name in param_dict.keys() if poly_param() == param_name]959 [createItem(param_name) for param_name in list(param_dict.keys()) if poly_param() == param_name] 957 960 958 961 error_column.append(item) … … 991 994 Take func and throw it inside the magnet model row loop 992 995 """ 993 for row_i in xrange(self._model_model.rowCount()):996 for row_i in range(self._model_model.rowCount()): 994 997 func(row_i) 995 998 … … 998 1001 # internal so can use closure for param_dict 999 1002 param_name = str(self._magnet_model.item(row, 0).text()) 1000 if param_name not in param_dict.keys():1003 if param_name not in list(param_dict.keys()): 1001 1004 return 1002 1005 # modify the param value … … 1016 1019 return str(self._magnet_model.item(row, 0).text()) 1017 1020 1018 [createItem(param_name) for param_name in param_dict.keys() if curr_param() == param_name]1021 [createItem(param_name) for param_name in list(param_dict.keys()) if curr_param() == param_name] 1019 1022 1020 1023 error_column.append(item) … … 1291 1294 # Unparsable field 1292 1295 return 1293 parameter_name = str(self._model_model.data(name_index) .toPyObject()) # sld, background etc.1296 parameter_name = str(self._model_model.data(name_index)) #.toPyObject()) # sld, background etc. 1294 1297 1295 1298 # Update the parameter value - note: this supports +/-inf as well … … 1357 1360 1358 1361 return [str(model.item(row_index, 0).text()) 1359 for row_index in xrange(model.rowCount())1362 for row_index in range(model.rowCount()) 1360 1363 if isChecked(row_index)] 1361 1364 … … 1398 1401 fitted_data.symbol = 'Line' 1399 1402 # Notify the GUI manager so it can update the main model in DataExplorer 1400 GuiUtils.updateModelItemWithPlot(self._index, QtCore.QVariant(fitted_data), name)1403 GuiUtils.updateModelItemWithPlot(self._index, fitted_data, name) 1401 1404 1402 1405 def createTheoryIndex(self, fitted_data): … … 1406 1409 name = self.nameFromData(fitted_data) 1407 1410 # Notify the GUI manager so it can create the theory model in DataExplorer 1408 new_item = GuiUtils.createModelItemWithPlot( QtCore.QVariant(fitted_data), name=name)1411 new_item = GuiUtils.createModelItemWithPlot(fitted_data, name=name) 1409 1412 self.communicate.updateTheoryFromPerspectiveSignal.emit(new_item) 1410 1413 … … 1460 1463 Thread returned error 1461 1464 """ 1462 print "Calculate Data failed with ", reason1465 print("Calculate Data failed with ", reason) 1463 1466 1464 1467 def complete1D(self, return_data): … … 1557 1560 else: 1558 1561 # Create as many entries as current shells 1559 for ishell in xrange(1, self.current_shell_displayed+1):1562 for ishell in range(1, self.current_shell_displayed+1): 1560 1563 # Remove [n] and add the shell numeral 1561 1564 name = param_name[0:param_name.index('[')] + str(ishell) … … 1585 1588 # All possible polydisp. functions as strings in combobox 1586 1589 func = QtGui.QComboBox() 1587 func.addItems([str(name_disp) for name_disp in POLYDISPERSITY_MODELS. iterkeys()])1590 func.addItems([str(name_disp) for name_disp in POLYDISPERSITY_MODELS.keys()]) 1588 1591 # Set the default index 1589 1592 func.setCurrentIndex(func.findText(DEFAULT_POLYDISP_FUNCTION)) … … 1636 1639 lo = self.lstPoly.itemDelegate().poly_pd 1637 1640 hi = self.lstPoly.itemDelegate().poly_function 1638 [self._poly_model.item(row_index, i).setEnabled(False) for i in xrange(lo, hi)]1641 [self._poly_model.item(row_index, i).setEnabled(False) for i in range(lo, hi)] 1639 1642 return 1640 1643 except IOError: … … 1646 1649 self._poly_model.blockSignals(True) 1647 1650 max_range = self.lstPoly.itemDelegate().poly_filename 1648 [self._poly_model.item(row_index, i).setEnabled(True) for i in xrange(7)]1651 [self._poly_model.item(row_index, i).setEnabled(True) for i in range(7)] 1649 1652 file_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_filename) 1650 self._poly_model.setData(file_index, QtCore.QVariant(""))1653 self._poly_model.setData(file_index, "") 1651 1654 self._poly_model.blockSignals(False) 1652 1655 … … 1657 1660 nsigs = POLYDISPERSITY_MODELS[str(combo_string)].default['nsigmas'] 1658 1661 1659 self._poly_model.setData(npts_index, QtCore.QVariant(npts))1660 self._poly_model.setData(nsigs_index, QtCore.QVariant(nsigs))1662 self._poly_model.setData(npts_index, npts) 1663 self._poly_model.setData(nsigs_index, nsigs) 1661 1664 1662 1665 self.iterateOverModel(updateFunctionCaption) … … 1669 1672 datafile = QtGui.QFileDialog.getOpenFileName( 1670 1673 self, "Choose a weight file", "", "All files (*.*)", 1671 None,QtGui.QFileDialog.DontUseNativeDialog)1674 QtGui.QFileDialog.DontUseNativeDialog) 1672 1675 1673 1676 if datafile is None or str(datafile)=='': … … 1698 1701 fname = os.path.basename(str(datafile)) 1699 1702 fname_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_filename) 1700 self._poly_model.setData(fname_index, QtCore.QVariant(fname))1703 self._poly_model.setData(fname_index, fname) 1701 1704 1702 1705 def setMagneticModel(self): … … 1720 1723 top_index = self.kernel_module.multiplicity_info.number 1721 1724 shell_names = [] 1722 for i in xrange(1, top_index+1):1725 for i in range(1, top_index+1): 1723 1726 for name in multi_names: 1724 1727 shell_names.append(name+str(i)) … … 1770 1773 func = QtGui.QComboBox() 1771 1774 # Available range of shells displayed in the combobox 1772 func.addItems([str(i) for i in xrange(param_length+1)])1775 func.addItems([str(i) for i in range(param_length+1)]) 1773 1776 1774 1777 # Respond to index change
Note: See TracChangeset
for help on using the changeset viewer.