Ignore:
Timestamp:
Nov 9, 2017 6:41:54 AM (6 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:
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)
Message:

Initial changes to make SasView? run with python3

File:
1 edited

Legend:

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

    re00b76e rb3e8629  
    22import os 
    33from collections import defaultdict 
    4 from itertools import izip 
     4 
    55 
    66import logging 
     
    7070        if role == QtCore.Qt.ToolTipRole: 
    7171            if orientation == QtCore.Qt.Horizontal: 
    72                 return QtCore.QString(str(self.header_tooltips[section])) 
     72                return str(self.header_tooltips[section]) 
    7373 
    7474        return QtGui.QStandardItemModel.headerData(self, section, orientation, role) 
     
    359359        # Similarly on other tabs 
    360360        self.options_widget.setEnablementOnDataLoad() 
    361  
    362         # Reload the model 
    363361        self.onSelectModel() 
    364  
    365362        # Smearing tab 
    366363        self.smearing_widget.updateSmearing(self.data) 
     
    482479        model = str(self.cbModel.currentText()) 
    483480 
     481        # empty combobox forced to be read 
     482        if not model: 
     483            return 
    484484        # Reset structure factor 
    485485        self.cbStructureFactor.setCurrentIndex(0) 
     
    772772        """ 
    773773        """ 
    774         print "UPDATE FIT" 
     774        print("UPDATE FIT") 
    775775        pass 
    776776 
     
    778778        """ 
    779779        """ 
    780         print "FIT FAILED: ", reason 
     780        print("FIT FAILED: ", reason) 
    781781        pass 
    782782 
     
    823823        param_values = res.pvec     # array([ 0.36221662,  0.0146783 ]) 
    824824        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)) 
    827827 
    828828        # Dictionary of fitted parameter: value, error 
     
    845845        Take func and throw it inside the model row loop 
    846846        """ 
    847         for row_i in xrange(self._model_model.rowCount()): 
     847        for row_i in range(self._model_model.rowCount()): 
    848848            func(row_i) 
    849849 
     
    860860            # internal so can use closure for param_dict 
    861861            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()): 
    863863                return 
    864864            # modify the param value 
     
    872872            # Utility function for updateof polydispersity part of the main model 
    873873            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()): 
    875875                return 
    876876            # modify the param value 
     
    887887                return str(self._model_model.item(row, 0).text()) 
    888888 
    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] 
    890890 
    891891            error_column.append(item) 
     
    931931            Take func and throw it inside the poly model row loop 
    932932            """ 
    933             for row_i in xrange(self._poly_model.rowCount()): 
     933            for row_i in range(self._poly_model.rowCount()): 
    934934                func(row_i) 
    935935 
     
    940940                return 
    941941            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()): 
    943943                return 
    944944            # modify the param value 
     
    963963                return str(self._poly_model.item(row_i, 0).text()).rsplit()[-1] + '.width' 
    964964 
    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] 
    966966 
    967967            error_column.append(item) 
     
    10001000            Take func and throw it inside the magnet model row loop 
    10011001            """ 
    1002             for row_i in xrange(self._model_model.rowCount()): 
     1002            for row_i in range(self._model_model.rowCount()): 
    10031003                func(row_i) 
    10041004 
     
    10071007            # internal so can use closure for param_dict 
    10081008            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()): 
    10101010                return 
    10111011            # modify the param value 
     
    10251025                return str(self._magnet_model.item(row, 0).text()) 
    10261026 
    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] 
    10281028 
    10291029            error_column.append(item) 
     
    13031303            # Unparsable field 
    13041304            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. 
    13061306 
    13071307        # Update the parameter value - note: this supports +/-inf as well 
     
    13691369 
    13701370        return [str(model.item(row_index, 0).text()) 
    1371                 for row_index in xrange(model.rowCount()) 
     1371                for row_index in range(model.rowCount()) 
    13721372                if isChecked(row_index)] 
    13731373 
     
    14101410            fitted_data.symbol = 'Line' 
    14111411        # 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) 
    14131413 
    14141414    def createTheoryIndex(self, fitted_data): 
     
    14181418        name = self.nameFromData(fitted_data) 
    14191419        # 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) 
    14211421        self.communicate.updateTheoryFromPerspectiveSignal.emit(new_item) 
    14221422 
     
    14721472        Thread returned error 
    14731473        """ 
    1474         print "Calculate Data failed with ", reason 
     1474        print("Calculate Data failed with ", reason) 
    14751475 
    14761476    def complete1D(self, return_data): 
     
    15691569            else: 
    15701570                # 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): 
    15721572                    # Remove [n] and add the shell numeral 
    15731573                    name = param_name[0:param_name.index('[')] + str(ishell) 
     
    15971597        # All possible polydisp. functions as strings in combobox 
    15981598        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()]) 
    16001600        # Set the default index 
    16011601        func.setCurrentIndex(func.findText(DEFAULT_POLYDISP_FUNCTION)) 
     
    16481648                lo = self.lstPoly.itemDelegate().poly_pd 
    16491649                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)] 
    16511651                return 
    16521652            except IOError: 
     
    16581658        self._poly_model.blockSignals(True) 
    16591659        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)] 
    16611661        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, "") 
    16631663        self._poly_model.blockSignals(False) 
    16641664 
     
    16691669        nsigs = POLYDISPERSITY_MODELS[str(combo_string)].default['nsigmas'] 
    16701670 
    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) 
    16731673 
    16741674        self.iterateOverModel(updateFunctionCaption) 
     
    16811681        datafile = QtGui.QFileDialog.getOpenFileName( 
    16821682            self, "Choose a weight file", "", "All files (*.*)", 
    1683             None, QtGui.QFileDialog.DontUseNativeDialog) 
     1683            QtGui.QFileDialog.DontUseNativeDialog) 
    16841684 
    16851685        if datafile is None or str(datafile)=='': 
     
    17101710        fname = os.path.basename(str(datafile)) 
    17111711        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) 
    17131713 
    17141714    def setMagneticModel(self): 
     
    17321732        top_index = self.kernel_module.multiplicity_info.number 
    17331733        shell_names = [] 
    1734         for i in xrange(1, top_index+1): 
     1734        for i in range(1, top_index+1): 
    17351735            for name in multi_names: 
    17361736                shell_names.append(name+str(i)) 
     
    17821782        func = QtGui.QComboBox() 
    17831783        # 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)]) 
    17851785 
    17861786        # Respond to index change 
Note: See TracChangeset for help on using the changeset viewer.