Changeset b3e8629 in sasview for src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
- Timestamp:
- Nov 9, 2017 6:41:54 AM (6 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:
- cee5c78
- Parents:
- 749b715
- git-author:
- Piotr Rozyczko <rozyczko@…> (10/26/17 01:13:05)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (11/09/17 06:41:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
re00b76e rb3e8629 2 2 import os 3 3 from collections import defaultdict 4 from itertools import izip 4 5 5 6 6 import logging … … 70 70 if role == QtCore.Qt.ToolTipRole: 71 71 if orientation == QtCore.Qt.Horizontal: 72 return QtCore.QString(str(self.header_tooltips[section]))72 return str(self.header_tooltips[section]) 73 73 74 74 return QtGui.QStandardItemModel.headerData(self, section, orientation, role) … … 359 359 # Similarly on other tabs 360 360 self.options_widget.setEnablementOnDataLoad() 361 362 # Reload the model363 361 self.onSelectModel() 364 365 362 # Smearing tab 366 363 self.smearing_widget.updateSmearing(self.data) … … 482 479 model = str(self.cbModel.currentText()) 483 480 481 # empty combobox forced to be read 482 if not model: 483 return 484 484 # Reset structure factor 485 485 self.cbStructureFactor.setCurrentIndex(0) … … 772 772 """ 773 773 """ 774 print "UPDATE FIT"774 print("UPDATE FIT") 775 775 pass 776 776 … … 778 778 """ 779 779 """ 780 print "FIT FAILED: ", reason780 print("FIT FAILED: ", reason) 781 781 pass 782 782 … … 823 823 param_values = res.pvec # array([ 0.36221662, 0.0146783 ]) 824 824 param_stderr = res.stderr # array([ 1.71293015, 1.71294233]) 825 params_and_errors = zip(param_values, param_stderr)826 param_dict = dict( izip(param_list, params_and_errors))825 params_and_errors = list(zip(param_values, param_stderr)) 826 param_dict = dict(zip(param_list, params_and_errors)) 827 827 828 828 # Dictionary of fitted parameter: value, error … … 845 845 Take func and throw it inside the model row loop 846 846 """ 847 for row_i in xrange(self._model_model.rowCount()):847 for row_i in range(self._model_model.rowCount()): 848 848 func(row_i) 849 849 … … 860 860 # internal so can use closure for param_dict 861 861 param_name = str(self._model_model.item(row, 0).text()) 862 if param_name not in param_dict.keys():862 if param_name not in list(param_dict.keys()): 863 863 return 864 864 # modify the param value … … 872 872 # Utility function for updateof polydispersity part of the main model 873 873 param_name = str(self._model_model.item(row, 0).text())+'.width' 874 if param_name not in param_dict.keys():874 if param_name not in list(param_dict.keys()): 875 875 return 876 876 # modify the param value … … 887 887 return str(self._model_model.item(row, 0).text()) 888 888 889 [createItem(param_name) for param_name in param_dict.keys() if curr_param() == param_name]889 [createItem(param_name) for param_name in list(param_dict.keys()) if curr_param() == param_name] 890 890 891 891 error_column.append(item) … … 931 931 Take func and throw it inside the poly model row loop 932 932 """ 933 for row_i in xrange(self._poly_model.rowCount()):933 for row_i in range(self._poly_model.rowCount()): 934 934 func(row_i) 935 935 … … 940 940 return 941 941 param_name = str(self._poly_model.item(row_i, 0).text()).rsplit()[-1] + '.width' 942 if param_name not in param_dict.keys():942 if param_name not in list(param_dict.keys()): 943 943 return 944 944 # modify the param value … … 963 963 return str(self._poly_model.item(row_i, 0).text()).rsplit()[-1] + '.width' 964 964 965 [createItem(param_name) for param_name in param_dict.keys() if poly_param() == param_name]965 [createItem(param_name) for param_name in list(param_dict.keys()) if poly_param() == param_name] 966 966 967 967 error_column.append(item) … … 1000 1000 Take func and throw it inside the magnet model row loop 1001 1001 """ 1002 for row_i in xrange(self._model_model.rowCount()):1002 for row_i in range(self._model_model.rowCount()): 1003 1003 func(row_i) 1004 1004 … … 1007 1007 # internal so can use closure for param_dict 1008 1008 param_name = str(self._magnet_model.item(row, 0).text()) 1009 if param_name not in param_dict.keys():1009 if param_name not in list(param_dict.keys()): 1010 1010 return 1011 1011 # modify the param value … … 1025 1025 return str(self._magnet_model.item(row, 0).text()) 1026 1026 1027 [createItem(param_name) for param_name in param_dict.keys() if curr_param() == param_name]1027 [createItem(param_name) for param_name in list(param_dict.keys()) if curr_param() == param_name] 1028 1028 1029 1029 error_column.append(item) … … 1303 1303 # Unparsable field 1304 1304 return 1305 parameter_name = str(self._model_model.data(name_index) .toPyObject()) # sld, background etc.1305 parameter_name = str(self._model_model.data(name_index)) #.toPyObject()) # sld, background etc. 1306 1306 1307 1307 # Update the parameter value - note: this supports +/-inf as well … … 1369 1369 1370 1370 return [str(model.item(row_index, 0).text()) 1371 for row_index in xrange(model.rowCount())1371 for row_index in range(model.rowCount()) 1372 1372 if isChecked(row_index)] 1373 1373 … … 1410 1410 fitted_data.symbol = 'Line' 1411 1411 # Notify the GUI manager so it can update the main model in DataExplorer 1412 GuiUtils.updateModelItemWithPlot(self._index, QtCore.QVariant(fitted_data), name)1412 GuiUtils.updateModelItemWithPlot(self._index, fitted_data, name) 1413 1413 1414 1414 def createTheoryIndex(self, fitted_data): … … 1418 1418 name = self.nameFromData(fitted_data) 1419 1419 # Notify the GUI manager so it can create the theory model in DataExplorer 1420 new_item = GuiUtils.createModelItemWithPlot( QtCore.QVariant(fitted_data), name=name)1420 new_item = GuiUtils.createModelItemWithPlot(fitted_data, name=name) 1421 1421 self.communicate.updateTheoryFromPerspectiveSignal.emit(new_item) 1422 1422 … … 1472 1472 Thread returned error 1473 1473 """ 1474 print "Calculate Data failed with ", reason1474 print("Calculate Data failed with ", reason) 1475 1475 1476 1476 def complete1D(self, return_data): … … 1569 1569 else: 1570 1570 # Create as many entries as current shells 1571 for ishell in xrange(1, self.current_shell_displayed+1):1571 for ishell in range(1, self.current_shell_displayed+1): 1572 1572 # Remove [n] and add the shell numeral 1573 1573 name = param_name[0:param_name.index('[')] + str(ishell) … … 1597 1597 # All possible polydisp. functions as strings in combobox 1598 1598 func = QtGui.QComboBox() 1599 func.addItems([str(name_disp) for name_disp in POLYDISPERSITY_MODELS. iterkeys()])1599 func.addItems([str(name_disp) for name_disp in POLYDISPERSITY_MODELS.keys()]) 1600 1600 # Set the default index 1601 1601 func.setCurrentIndex(func.findText(DEFAULT_POLYDISP_FUNCTION)) … … 1648 1648 lo = self.lstPoly.itemDelegate().poly_pd 1649 1649 hi = self.lstPoly.itemDelegate().poly_function 1650 [self._poly_model.item(row_index, i).setEnabled(False) for i in xrange(lo, hi)]1650 [self._poly_model.item(row_index, i).setEnabled(False) for i in range(lo, hi)] 1651 1651 return 1652 1652 except IOError: … … 1658 1658 self._poly_model.blockSignals(True) 1659 1659 max_range = self.lstPoly.itemDelegate().poly_filename 1660 [self._poly_model.item(row_index, i).setEnabled(True) for i in xrange(7)]1660 [self._poly_model.item(row_index, i).setEnabled(True) for i in range(7)] 1661 1661 file_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_filename) 1662 self._poly_model.setData(file_index, QtCore.QVariant(""))1662 self._poly_model.setData(file_index, "") 1663 1663 self._poly_model.blockSignals(False) 1664 1664 … … 1669 1669 nsigs = POLYDISPERSITY_MODELS[str(combo_string)].default['nsigmas'] 1670 1670 1671 self._poly_model.setData(npts_index, QtCore.QVariant(npts))1672 self._poly_model.setData(nsigs_index, QtCore.QVariant(nsigs))1671 self._poly_model.setData(npts_index, npts) 1672 self._poly_model.setData(nsigs_index, nsigs) 1673 1673 1674 1674 self.iterateOverModel(updateFunctionCaption) … … 1681 1681 datafile = QtGui.QFileDialog.getOpenFileName( 1682 1682 self, "Choose a weight file", "", "All files (*.*)", 1683 None,QtGui.QFileDialog.DontUseNativeDialog)1683 QtGui.QFileDialog.DontUseNativeDialog) 1684 1684 1685 1685 if datafile is None or str(datafile)=='': … … 1710 1710 fname = os.path.basename(str(datafile)) 1711 1711 fname_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_filename) 1712 self._poly_model.setData(fname_index, QtCore.QVariant(fname))1712 self._poly_model.setData(fname_index, fname) 1713 1713 1714 1714 def setMagneticModel(self): … … 1732 1732 top_index = self.kernel_module.multiplicity_info.number 1733 1733 shell_names = [] 1734 for i in xrange(1, top_index+1):1734 for i in range(1, top_index+1): 1735 1735 for name in multi_names: 1736 1736 shell_names.append(name+str(i)) … … 1782 1782 func = QtGui.QComboBox() 1783 1783 # Available range of shells displayed in the combobox 1784 func.addItems([str(i) for i in xrange(param_length+1)])1784 func.addItems([str(i) for i in range(param_length+1)]) 1785 1785 1786 1786 # Respond to index change
Note: See TracChangeset
for help on using the changeset viewer.