Changeset b3e8629 in sasview


Ignore:
Timestamp:
Nov 9, 2017 8:41:54 AM (7 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 03:13:05)
git-committer:
Piotr Rozyczko <rozyczko@…> (11/09/17 08:41:54)
Message:

Initial changes to make SasView? run with python3

Location:
src/sas
Files:
56 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Calculators/DataOperationUtilityPanel.py

    • Property mode changed from 100644 to 100755
    r7d9c83c rb3e8629  
    1313import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    1414 
    15 from UI.DataOperationUtilityUI import Ui_DataOperationUtility 
     15from .UI.DataOperationUtilityUI import Ui_DataOperationUtility 
    1616 
    1717BG_WHITE = "background-color: rgb(255, 255, 255);" 
     
    7676        self.filenames = filenames 
    7777 
    78         if filenames.keys(): 
     78        if list(filenames.keys()): 
    7979            # clear contents of comboboxes 
    8080            self.cbData1.clear() 
     
    8585            list_datafiles = [] 
    8686 
    87             for key_id in filenames.keys(): 
     87            for key_id in list(filenames.keys()): 
    8888                if filenames[key_id].get_data().title: 
    8989                    # filenames with titles 
     
    139139            data1 = self.data1 
    140140            data2 = self.data2 
    141             exec "output = data1 %s data2" % operator 
     141            exec("output = data1 %s data2" % operator) 
    142142        except: 
    143143            raise 
     
    300300                self.cbData1.setStyleSheet(QtCore.QString(BG_RED)) 
    301301                self.cbData2.setStyleSheet(QtCore.QString(BG_RED)) 
    302                 print self.data1.__class__.__name__ != self.data2.__class__.__name__ 
     302                print(self.data1.__class__.__name__ != self.data2.__class__.__name__) 
    303303                logging.warning('Cannot compute data of different dimensions') 
    304304                return False 
     
    354354    def _findId(self, name): 
    355355        """ find id of name in list of filenames """ 
    356         isinstance(name, basestring) 
    357  
    358         for key_id in self.filenames.keys(): 
     356        isinstance(name, str) 
     357 
     358        for key_id in list(self.filenames.keys()): 
    359359            # data with title 
    360360            if self.filenames[key_id].get_data().title: 
  • src/sas/qtgui/Calculators/DensityPanel.py

    • Property mode changed from 100644 to 100755
    rb0c5e8c rb3e8629  
    1414 
    1515def enum(*sequential, **named): 
    16     enums = dict(zip(sequential, range(len(sequential))), **named) 
     16    enums = dict(list(zip(sequential, list(range(len(sequential))))), **named) 
    1717    return type('Enum', (), enums) 
    1818 
     
    9595 
    9696    def dataChanged(self, top, bottom): 
    97         for index in xrange(top.row(), bottom.row() + 1): 
     97        for index in range(top.row(), bottom.row() + 1): 
    9898            if index == MODEL.MOLECULAR_FORMULA: 
    9999                molarMass = toMolarMass(self.model.item(MODEL.MOLECULAR_FORMULA).text()) 
  • src/sas/qtgui/Calculators/GenericScatteringCalculator.py

    • Property mode changed from 100644 to 100755
    rfef38e8 rb3e8629  
    2222 
    2323# Local UI 
    24 from UI.GenericScatteringCalculator import Ui_GenericScatteringCalculator 
     24from .UI.GenericScatteringCalculator import Ui_GenericScatteringCalculator 
    2525 
    2626_Q1D_MIN = 0.001 
     
    119119        TODO Temporary solution to display information about option 'Ellipsoid' 
    120120        """ 
    121         print "The option Ellipsoid has not been implemented yet." 
     121        print("The option Ellipsoid has not been implemented yet.") 
    122122        self.communicator.statusBarUpdateSignal.emit( 
    123123            "The option Ellipsoid has not been implemented yet.") 
     
    165165                self.reader.queue() 
    166166        except (RuntimeError, IOError): 
    167             log_msg = "Generic SAS Calculator: %s" % sys.exc_value 
     167            log_msg = "Generic SAS Calculator: %s" % sys.exc_info()[1] 
    168168            logging.info(log_msg) 
    169169            raise 
     
    556556            d.addCallback(self.plot_1_2d) 
    557557        except: 
    558             log_msg = "{}. stop".format(sys.exc_value) 
     558            log_msg = "{}. stop".format(sys.exc_info()[1]) 
    559559            logging.info(log_msg) 
    560560        return 
     
    644644            self.graph_num += 1 
    645645            # TODO 
    646             print 'TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED' 
     646            print('TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED') 
    647647            return plot1D 
    648648        else: 
     
    662662            self.graph_num += 1 
    663663            # TODO 
    664             print 'TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED' 
     664            print('TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED') 
    665665            return plot2D 
    666666 
     
    744744        # II. Plot selective points in color 
    745745        other_color = numpy.ones(len(pix_symbol), dtype='bool') 
    746         for key in color_dic.keys(): 
     746        for key in list(color_dic.keys()): 
    747747            chosen_color = pix_symbol == key 
    748748            if numpy.any(chosen_color): 
     
    758758                # Get atom names not in the list 
    759759                a_names = [symb for symb in pix_symbol \ 
    760                            if symb not in color_dic.keys()] 
     760                           if symb not in list(color_dic.keys())] 
    761761                a_name = a_names[0] 
    762762                for name in a_names: 
  • src/sas/qtgui/Calculators/KiessigPanel.py

    • Property mode changed from 100644 to 100755
    rb0c5e8c rb3e8629  
    33 
    44from sas.qtgui.UI import main_resources_rc 
    5 from UI.KiessigPanel import Ui_KiessigPanel 
     5from .UI.KiessigPanel import Ui_KiessigPanel 
    66import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    77 
  • src/sas/qtgui/Calculators/ResolutionCalculatorPanel.py

    • Property mode changed from 100644 to 100755
    r170e95d rb3e8629  
    2020import re 
    2121 
    22 from UI.ResolutionCalculatorPanelUI import Ui_ResolutionCalculatorPanel 
     22from .UI.ResolutionCalculatorPanelUI import Ui_ResolutionCalculatorPanel 
    2323 
    2424_SOURCE_MASS = {'Alpha': 6.64465620E-24, 
     
    318318                self, "Choose a spectral distribution file", "", 
    319319                "All files (*.*)", 
    320                 None, QtGui.QFileDialog.DontUseNativeDialog) 
     320                QtGui.QFileDialog.DontUseNativeDialog) 
    321321 
    322322            if datafile is None or str(datafile) == '': 
     
    328328            try: 
    329329                basename = os.path.basename(datafile) 
    330                 if basename not in self.spectrum_dic.keys(): 
     330                if basename not in list(self.spectrum_dic.keys()): 
    331331                    self.cbCustomSpectrum.addItem(basename) 
    332332 
     
    604604                msg = "The numbers must be one or two (separated by ',')" 
    605605                logging.info(msg) 
    606                 raise RuntimeError, msg 
     606                raise RuntimeError(msg) 
    607607 
    608608        return new_numbers_list 
     
    618618            new_list = [float(t) for t in string_split] 
    619619        except: 
    620             logging.error(sys.exc_value) 
     620            logging.error(sys.exc_info()[1]) 
    621621        return new_list 
    622622 
     
    658658                        return out 
    659659                except: 
    660                     logging.error(sys.exc_value) 
     660                    logging.error(sys.exc_info()[1]) 
    661661 
    662662    def _validate_q_input(self, qx, qy): 
  • src/sas/qtgui/Calculators/SldPanel.py

    • Property mode changed from 100644 to 100755
    rb0c5e8c rb3e8629  
    1515 
    1616def enum(*sequential, **named): 
    17     enums = dict(zip(sequential, range(len(sequential))), **named) 
     17    enums = dict(list(zip(sequential, list(range(len(sequential))))), **named) 
    1818    return type('Enum', (), enums) 
    1919 
     
    6060        if len(formula.atoms) != 1: 
    6161            raise NotImplementedError() 
    62         energy = xray_energy(formula.atoms.keys()[0].K_alpha) 
     62        energy = xray_energy(list(formula.atoms.keys())[0].K_alpha) 
    6363        return xray_sld_from_atoms( 
    6464            sld_formula.atoms, 
     
    142142        self.model.setItem(MODEL.WAVELENGTH       , QtGui.QStandardItem()) 
    143143 
    144         for key in self._getOutputs().keys(): 
     144        for key in list(self._getOutputs().keys()): 
    145145            self.model.setItem(key, QtGui.QStandardItem()) 
    146146 
     
    161161        self.mapper.addMapping(self.ui.editWavelength      , MODEL.WAVELENGTH) 
    162162 
    163         for key, edit in self._getOutputs().iteritems(): 
     163        for key, edit in self._getOutputs().items(): 
    164164            self.mapper.addMapping(edit, key) 
    165165 
     
    168168    def dataChanged(self, top, bottom): 
    169169        update = False 
    170         for index in xrange(top.row(), bottom.row() + 1): 
     170        for index in range(top.row(), bottom.row() + 1): 
    171171            if (index == MODEL.MOLECULAR_FORMULA) or (index == MODEL.MASS_DENSITY) or (index == MODEL.WAVELENGTH): 
    172172                update = True 
     
    202202                    pass 
    203203 
    204             for key in self._getOutputs().keys(): 
     204            for key in list(self._getOutputs().keys()): 
    205205                self.model.item(key).setText("") 
    206206 
  • src/sas/qtgui/Calculators/SlitSizeCalculator.py

    • Property mode changed from 100644 to 100755
    rf4a1433 rb3e8629  
    1111import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    1212 
    13 from UI.SlitSizeCalculator import Ui_SlitSizeCalculator 
     13from .UI.SlitSizeCalculator import Ui_SlitSizeCalculator 
    1414from sas.sascalc.dataloader.loader import Loader 
    1515from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator 
     
    7676        # But only with Qt built-in dialog (non-platform native) 
    7777        path = QtGui.QFileDialog.getOpenFileName(self, "Choose a file", "", 
    78                                                  "SAXSess 1D data (*.txt *.TXT *.dat *.DAT)", None, 
     78                                                 "SAXSess 1D data (*.txt *.TXT *.dat *.DAT)", 
    7979                                                 QtGui.QFileDialog.DontUseNativeDialog) 
    8080 
     
    107107            self.clearResults() 
    108108            msg = "ERROR: Data hasn't been loaded correctly" 
    109             raise RuntimeError, msg 
     109            raise RuntimeError(msg) 
    110110 
    111111        if data.__class__.__name__ == 'Data2D': 
    112112            self.clearResults() 
    113113            msg = "Slit Length cannot be computed for 2D Data" 
    114             raise RuntimeError, msg 
     114            raise RuntimeError(msg) 
    115115 
    116116        #compute the slit size 
     
    120120            if xdata == [] or xdata is None or ydata == [] or ydata is None: 
    121121                msg = "The current data is empty please check x and y" 
    122                 raise ValueError, msg 
     122                raise ValueError(msg) 
    123123            slit_length_calculator = SlitlengthCalculator() 
    124124            slit_length_calculator.set_data(x=xdata, y=ydata) 
     
    126126        except: 
    127127            self.clearResults() 
    128             msg = "Slit Size Calculator: %s" % (sys.exc_value) 
    129             raise RuntimeError, msg 
     128            msg = "Slit Size Calculator: %s" % (sys.exc_info()[1]) 
     129            raise RuntimeError(msg) 
    130130 
    131131        slit_length_str = "{:.5f}".format(slit_length) 
  • src/sas/qtgui/Calculators/UnitTesting/SlitSizeCalculatorTest.py

    • Property mode changed from 100644 to 100755
    rf4a1433 rb3e8629  
    8484        loader = Loader() 
    8585        data = loader.load(filename)[0] 
    86         self.assertRaisesRegexp(RuntimeError, 
     86        self.assertRaisesRegex(RuntimeError, 
    8787                                "Slit Length cannot be computed for 2D Data", 
    8888                                self.widget.calculateSlitSize, data) 
    8989 
    9090        data = None 
    91         self.assertRaisesRegexp(RuntimeError, 
     91        self.assertRaisesRegex(RuntimeError, 
    9292                                "ERROR: Data hasn't been loaded correctly", 
    9393                                self.widget.calculateSlitSize, data) 
  • src/sas/qtgui/MainWindow/AboutBox.py

    • Property mode changed from 100644 to 100755
    rcd2cc745 rb3e8629  
    88from sas.qtgui.UI import main_resources_rc 
    99 
    10 from UI.AboutUI import Ui_AboutUI 
     10from .UI.AboutUI import Ui_AboutUI 
    1111 
    1212class AboutBox(QtGui.QDialog, Ui_AboutUI): 
  • src/sas/qtgui/MainWindow/DataExplorer.py

    • Property mode changed from 100644 to 100755
    r88e1f57 rb3e8629  
    155155        Populate the Perspective combobox and define callbacks 
    156156        """ 
    157         available_perspectives = sorted([p for p in Perspectives.PERSPECTIVES.keys()]) 
     157        available_perspectives = sorted([p for p in list(Perspectives.PERSPECTIVES.keys())]) 
    158158        if available_perspectives: 
    159159            self.cbFitting.clear() 
     
    240240 
    241241        self.manager.assign(manager) 
    242         for id, item in self.manager.get_all_data().iteritems(): 
     242        for id, item in self.manager.get_all_data().items(): 
    243243            self.updateModel(item.data, item.path) 
    244244 
     
    345345        # Figure out which rows are checked 
    346346        selected_items = [self.model.item(index) 
    347                           for index in xrange(self.model.rowCount()) 
     347                          for index in range(self.model.rowCount()) 
    348348                          if isItemReady(index)] 
    349349 
     
    400400        else: 
    401401            freeze_msg = "Unexpected number of theories copied: %i" % theories_copied 
    402             raise AttributeError, freeze_msg 
     402            raise AttributeError(freeze_msg) 
    403403        self.communicator.statusBarUpdateSignal.emit(freeze_msg) 
    404404        # Actively switch tabs 
     
    411411        new_item = item.clone() 
    412412        # clone doesn't do deepcopy :( 
    413         for child_index in xrange(item.rowCount()): 
     413        for child_index in range(item.rowCount()): 
    414414            child_item = self.recursivelyCloneItem(item.child(child_index)) 
    415415            new_item.setChild(child_index, child_item) 
     
    435435            return 
    436436        new_plots = [PlotHelper.plotById(plot) for plot in graph_list] 
    437         active_plots_copy = self.active_plots.keys() 
     437        active_plots_copy = list(self.active_plots.keys()) 
    438438        for plot in active_plots_copy: 
    439439            if self.active_plots[plot] in new_plots: 
     
    478478        for plot in plots: 
    479479            plot_id = plot.id 
    480             if plot_id in self.active_plots.keys(): 
     480            if plot_id in list(self.active_plots.keys()): 
    481481                self.active_plots[plot_id].replacePlot(plot_id, plot) 
    482482            else: 
     
    530530            else: 
    531531                msg = "Incorrect data type passed to Plotting" 
    532                 raise AttributeError, msg 
     532                raise AttributeError(msg) 
    533533 
    534534        if 'new_plot' in locals() and \ 
     
    597597 
    598598        id = data.id 
    599         if data.id in self.active_plots.keys(): 
     599        if data.id in list(self.active_plots.keys()): 
    600600            self.active_plots[id].replacePlot(id, data) 
    601601 
     
    610610        # But only with Qt built-in dialog (non-platform native) 
    611611        paths = QtGui.QFileDialog.getOpenFileNames(self, "Choose a file", "", 
    612                 wlist, None, QtGui.QFileDialog.DontUseNativeDialog) 
     612                wlist, QtGui.QFileDialog.DontUseNativeDialog) 
    613613        if paths is None: 
    614614            return 
    615615 
    616         if isinstance(paths, QtCore.QStringList): 
    617             paths = [str(f) for f in paths] 
     616        #if isinstance(paths, QtCore.QStringList): 
     617        #    paths = [str(f) for f in paths] 
    618618 
    619619        if not isinstance(paths, list): 
     
    687687 
    688688            except Exception as ex: 
    689                 logging.error(sys.exc_value) 
     689                logging.error(sys.exc_info()[1]) 
    690690 
    691691                any_error = True 
     
    747747        if not isinstance(index, int): 
    748748            msg = "Incorrect type passed to DataExplorer.selectData()" 
    749             raise AttributeError, msg 
     749            raise AttributeError(msg) 
    750750 
    751751        # Respond appropriately 
     
    773773                except AttributeError: 
    774774                    msg = "Bad structure of the data model." 
    775                     raise RuntimeError, msg 
     775                    raise RuntimeError(msg) 
    776776 
    777777                if is1D: 
     
    787787                except AttributeError: 
    788788                    msg = "Bad structure of the data model." 
    789                     raise RuntimeError, msg 
     789                    raise RuntimeError(msg) 
    790790 
    791791                if item.isCheckable() and item.checkState() == QtCore.Qt.Checked and is1D: 
     
    801801                except AttributeError: 
    802802                    msg = "Bad structure of the data model." 
    803                     raise RuntimeError, msg 
     803                    raise RuntimeError(msg) 
    804804 
    805805                if is2D: 
     
    815815                except AttributeError: 
    816816                    msg = "Bad structure of the data model." 
    817                     raise RuntimeError, msg 
     817                    raise RuntimeError(msg) 
    818818 
    819819                if item.isCheckable() and item.checkState() == QtCore.Qt.Checked and is2D: 
     
    823823            msg = "Incorrect value in the Selection Option" 
    824824            # Change this to a proper logging action 
    825             raise Exception, msg 
     825            raise Exception(msg) 
    826826 
    827827    def contextMenu(self): 
     
    10161016        # Add the actual Data1D/Data2D object 
    10171017        object_item = QtGui.QStandardItem() 
    1018         object_item.setData(QtCore.QVariant(data)) 
     1018        object_item.setData(data) 
    10191019 
    10201020        checkbox_item.setChild(0, object_item) 
     
    10401040        if not isinstance(model_item, QtGui.QStandardItem): 
    10411041            msg = "Wrong data type returned from calculations." 
    1042             raise AttributeError, msg 
     1042            raise AttributeError(msg) 
    10431043 
    10441044        # TODO: Assert other properties 
     
    10571057        if not isinstance(model_item, QtGui.QStandardItem): 
    10581058            msg = "Wrong data type returned from calculations." 
    1059             raise AttributeError, msg 
     1059            raise AttributeError(msg) 
    10601060 
    10611061        # Check if there are any other items for this tab 
     
    10641064        #  
    10651065        current_tab_name = model_item.text()[:2] 
    1066         for current_index in xrange(self.theory_model.rowCount()): 
     1066        for current_index in range(self.theory_model.rowCount()): 
    10671067            if current_tab_name in self.theory_model.item(current_index).text(): 
    10681068                self.theory_model.removeRow(current_index) 
  • src/sas/qtgui/MainWindow/DataManager.py

    • Property mode changed from 100644 to 100755
    rf4a1433 rb3e8629  
    2424import json 
    2525import time 
    26 from StringIO import StringIO 
     26from io import StringIO 
    2727import numpy as np 
    2828 
     
    6666        _str += "No of states  is %s \n" % str(len(self.stored_data)) 
    6767        n_count = 0 
    68         for  value in self.stored_data.values(): 
     68        for  value in list(self.stored_data.values()): 
    6969            n_count += 1 
    7070            _str += "State No %s \n"  % str(n_count) 
     
    146146        receive a list of 
    147147        """ 
    148         for id, data in data_list.iteritems(): 
     148        for id, data in data_list.items(): 
    149149            if id  in self.stored_data: 
    150150                msg = "Data manager already stores %s" % str(data.name) 
     
    162162        """ 
    163163        """ 
    164         if prev_data.id not in self.stored_data.keys(): 
     164        if prev_data.id not in list(self.stored_data.keys()): 
    165165            return None, {} 
    166166        data_state = self.stored_data[prev_data.id] 
    167167        self.stored_data[new_data.id]  = data_state.clone() 
    168168        self.stored_data[new_data.id].data = new_data 
    169         if prev_data.id in self.stored_data.keys(): 
     169        if prev_data.id in list(self.stored_data.keys()): 
    170170            del self.stored_data[prev_data.id] 
    171171        return prev_data.id, {new_data.id: self.stored_data[new_data.id]} 
     
    177177        if data_id is None and theory is not None: 
    178178            uid = theory.id 
    179         if uid in self.stored_data.keys(): 
     179        if uid in list(self.stored_data.keys()): 
    180180             data_state = self.stored_data[uid] 
    181181        else: 
     
    207207                if search_id == d_id: 
    208208                    _selected_data[search_id] = data 
    209                 if search_id in theory_list.keys(): 
     209                if search_id in list(theory_list.keys()): 
    210210                     _selected_theory_list[search_id] = theory_list[search_id] 
    211211 
     
    216216        """ 
    217217        """ 
    218         return self.freeze_theory(self.stored_data.keys(), theory_id) 
     218        return self.freeze_theory(list(self.stored_data.keys()), theory_id) 
    219219 
    220220    def freeze_theory(self, data_id, theory_id): 
     
    227227                theory_list = data_state.get_theory() 
    228228                for t_id in theory_id: 
    229                     if t_id in theory_list.keys(): 
     229                    if t_id in list(theory_list.keys()): 
    230230                        theory_data, theory_state = theory_list[t_id] 
    231231                        new_theory = copy.deepcopy(theory_data) 
     
    247247        """ 
    248248        for d_id in data_id: 
    249             if d_id in self.stored_data.keys(): 
     249            if d_id in list(self.stored_data.keys()): 
    250250                data_state = self.stored_data[d_id] 
    251251                if data_state.data.name in self.data_name_dict: 
     
    265265                data_state = self.stored_data[d_id] 
    266266                theory_list = data_state.get_theory() 
    267                 if theory_id in theory_list.keys(): 
     267                if theory_id in list(theory_list.keys()): 
    268268                    del theory_list[theory_id] 
    269269        #del pure theory 
     
    284284        _selected_data = {} 
    285285        for selected_name in name_list: 
    286             for id, data_state in self.stored_data.iteritems(): 
     286            for id, data_state in self.stored_data.items(): 
    287287                if data_state.data.name == selected_name: 
    288288                    _selected_data[id] = data_state.data 
     
    294294        """ 
    295295        for selected_name in name_list: 
    296             for id, data_state in self.stored_data.iteritems(): 
     296            for id, data_state in self.stored_data.items(): 
    297297                if data_state.data.name == selected_name: 
    298298                    del self.stored_data[id] 
     
    303303            # Take the copy of current, possibly shorter stored_data dict 
    304304            stored_data = copy.deepcopy(self.stored_data) 
    305             for idx in stored_data.keys(): 
     305            for idx in list(stored_data.keys()): 
    306306                if str(selected_name) in str(idx): 
    307307                    del self.stored_data[idx] 
     
    313313        _selected_data_state = {} 
    314314        for id in data_id: 
    315             if id in self.stored_data.keys(): 
     315            if id in list(self.stored_data.keys()): 
    316316                _selected_data_state[id] = self.stored_data[id] 
    317317        return _selected_data_state 
     
    396396            class Empty(object): 
    397397                def __init__(self): 
    398                     for key, value in data.iteritems(): 
     398                    for key, value in data.items(): 
    399399                        setattr(self, key, generate(value, level)) 
    400400 
     
    451451                    # if dictionary doesn't have __type__ then it is assumed to be just an ordinary dictionary 
    452452                    o = {} 
    453                     for key, value in data.iteritems(): 
     453                    for key, value in data.items(): 
    454454                        o[key] = generate(value, level) 
    455455                    return o 
     
    463463 
    464464        new_stored_data = {} 
    465         for id, data in json.load(fp).iteritems(): 
     465        for id, data in json.load(fp).items(): 
    466466            try: 
    467467                new_stored_data[id] = generate(data, 0) 
  • src/sas/qtgui/MainWindow/DataState.py

    r749b715 rb3e8629  
    3737        _str += "Theories available: %s \n" % len(self.theory_list) 
    3838        if self.theory_list: 
    39             for id, item in self.theory_list.iteritems(): 
     39            for id, item in self.theory_list.items(): 
    4040                theory_data, theory_state = item 
    4141                _str += "Theory name : %s \n" % str(theory_data.name) 
     
    5353        obj.message = self.message 
    5454        obj.id = self.id 
    55         for id, item in self.theory_list.iteritems(): 
     55        for id, item in self.theory_list.items(): 
    5656            theory_data, theory_state = item 
    5757            state = None 
     
    9595        """ 
    9696        self.theory_list[theory_data.id] = [theory_data, theory_state] 
    97         data, state = self.theory_list.values()[0] 
     97        data, state = list(self.theory_list.values())[0] 
    9898        
    9999    def get_theory(self): 
  • src/sas/qtgui/MainWindow/GuiManager.py

    • Property mode changed from 100644 to 100755
    r9e54199 rb3e8629  
    199199        workspace_height = self._workspace.workspace.sizeHint().height() 
    200200        perspective_size = self._current_perspective.sizeHint() 
    201         if workspace_height < perspective_size.height: 
     201        if workspace_height < perspective_size.height(): 
    202202            perspective_width = perspective_size.width() 
    203203            self._current_perspective.resize(perspective_width, workspace_height-10) 
     
    210210        assert isinstance(data, list) 
    211211        if self._current_perspective is not None: 
    212             self._current_perspective.setData(data.values()) 
     212            self._current_perspective.setData(list(data.values())) 
    213213        else: 
    214214            msg = "No perspective is currently active." 
     
    254254        """ 
    255255        if self._current_perspective is not None: 
    256             self._current_perspective.setData(data.values()) 
     256            self._current_perspective.setData(list(data.values())) 
    257257        else: 
    258258            msg = "Guiframe does not have a current perspective" 
     
    297297            version_info = json.loads(content) 
    298298            self.processVersion(version_info) 
    299         except ValueError, ex: 
     299        except ValueError as ex: 
    300300            logging.info("Failed to connect to www.sasview.org:", ex) 
    301301 
     
    329329        except: 
    330330            msg = "guiframe: could not get latest application" 
    331             msg += " version number\n  %s" % sys.exc_value 
     331            msg += " version number\n  %s" % sys.exc_info()[1] 
    332332            logging.error(msg) 
    333333            msg = "Could not connect to the application server." 
     
    764764                not isinstance(new_datalist_item, dict): 
    765765            msg = "Wrong data type returned from calculations." 
    766             raise AttributeError, msg 
     766            raise AttributeError(msg) 
    767767 
    768768        self.filesWidget.model.appendRow(new_item) 
  • src/sas/qtgui/MainWindow/MainWindow.py

    • Property mode changed from 100644 to 100755
    r2a8bd705 rb3e8629  
    55# Local UI 
    66from sas.qtgui.UI import main_resources_rc 
    7 from UI.MainWindowUI import Ui_MainWindow 
     7from .UI.MainWindowUI import Ui_MainWindow 
    88 
    99# Initialize logging 
     
    2121 
    2222        # Create the gui manager 
    23         from GuiManager import GuiManager 
     23        from .GuiManager import GuiManager 
    2424        self.guiManager = GuiManager(self) 
    2525 
  • src/sas/qtgui/Perspectives/Fitting/FitThread.py

    ree18d33 rb3e8629  
    1414 
    1515def map_apply(arguments): 
    16     return apply(arguments[0], arguments[1:]) 
     16    return arguments[0](*arguments[1:]) 
    1717 
    1818class FitThread(CalcThread): 
     
    5555        except KeyboardInterrupt: 
    5656            msg = "Fitting: terminated by the user." 
    57             raise KeyboardInterrupt, msg 
     57            raise KeyboardInterrupt(msg) 
    5858 
    5959    def compute(self): 
     
    7171            list_q = [None]*fitter_size 
    7272 
    73             inputs = zip(list_map_get_attr, self.fitter, list_fit_function, 
     73            inputs = list(zip(list_map_get_attr, self.fitter, list_fit_function, 
    7474                         list_q, list_q, list_handler, list_curr_thread, 
    75                          list_reset_flag) 
    76             result = map(map_apply, inputs) 
     75                         list_reset_flag)) 
     76            result = list(map(map_apply, inputs)) 
    7777            results = (result, time.time()-self.starttime) 
    7878            if self.handler: 
     
    8181                return (results) 
    8282 
    83         except KeyboardInterrupt, msg: 
     83        except KeyboardInterrupt as msg: 
    8484            # Thread was interrupted, just proceed and re-raise. 
    8585            # Real code should not print, but this is an example... 
  • src/sas/qtgui/Perspectives/Fitting/FittingLogic.py

    ree18d33 rb3e8629  
    196196                msg = "Unable to find min/max/length of \n data named %s" % \ 
    197197                            self.data.filename 
    198                 raise ValueError, msg 
     198                raise ValueError(msg) 
    199199 
    200200        else: 
     
    206206                msg = "Unable to find min/max of \n data named %s" % \ 
    207207                            self.data.filename 
    208                 raise ValueError, msg 
     208                raise ValueError(msg) 
    209209            qmax = np.sqrt(x * x + y * y) 
    210210            npts = len(data.data) 
  • src/sas/qtgui/Perspectives/Fitting/FittingOptions.py

    r377ade1 rb3e8629  
    8080        Use options.FIT_FIELDS to assert which line edit gets what validator 
    8181        """ 
    82         for option in bumps.options.FIT_FIELDS.iterkeys(): 
     82        for option in bumps.options.FIT_FIELDS.keys(): 
    8383            (f_name, f_type) = bumps.options.FIT_FIELDS[option] 
    8484            validator = None 
     
    8686                validator = QtGui.QIntValidator() 
    8787                validator.setBottom(0) 
    88             elif f_type == types.FloatType: 
     88            elif f_type == float: 
    8989                validator = QtGui.QDoubleValidator() 
    9090                validator.setBottom(0) 
     
    153153 
    154154        # Update the BUMPS singleton 
    155         [bumpsUpdate(o) for o in self.config.values[self.current_fitter_id].iterkeys()] 
     155        [bumpsUpdate(o) for o in self.config.values[self.current_fitter_id].keys()] 
    156156 
    157157    def onHelp(self): 
     
    175175        if current_fitter is None: 
    176176            current_fitter = self.current_fitter_id 
    177         if option_id not in bumps.options.FIT_FIELDS.keys(): return None 
     177        if option_id not in list(bumps.options.FIT_FIELDS.keys()): return None 
    178178        option = option_id + '_' + current_fitter 
    179179        if not hasattr(self, option): return None 
     
    193193        """ 
    194194        options = self.config.values[fitter_id] 
    195         for option in options.iterkeys(): 
     195        for option in options.keys(): 
    196196            # Find the widget name of the option 
    197197            # e.g. 'samples' for 'dream' is 'self.samples_dream' 
  • src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py

    r14fa542 rb3e8629  
    1212from sas.qtgui.Perspectives.Fitting.FittingOptions import FittingOptions 
    1313from sas.qtgui.Perspectives.Fitting.GPUOptions import GPUOptions 
    14 from sas.qtgui.Perspectives.Fitting import ModelUtilities 
     14#from sas.qtgui.Perspectives.Fitting import ModelUtilities 
    1515 
    1616class FittingWindow(QtGui.QTabWidget): 
     
    6464        # GPU Options 
    6565        self.gpu_options_widget = GPUOptions(self) 
    66  
    67         self.menu_manager = ModelUtilities.ModelManager() 
    68         # TODO: reuse these in FittingWidget properly 
    69         self.model_list_box = self.menu_manager.get_model_list() 
    70         self.model_dictionary = self.menu_manager.get_model_dictionary() 
    7166 
    7267        #self.setWindowTitle('Fit panel - Active Fitting Optimizer: %s' % self.optimizer) 
     
    124119        Create a list if none exists and append if there's already a list 
    125120        """ 
    126         if item_key in self.dataToFitTab.keys(): 
    127             self.dataToFitTab[item_key].append(tab_name) 
     121        item_key_str = str(item_key) 
     122        if item_key_str in list(self.dataToFitTab.keys()): 
     123            self.dataToFitTab[item_key_str].append(tab_name) 
    128124        else: 
    129             self.dataToFitTab[item_key] = [tab_name] 
     125            self.dataToFitTab[item_key_str] = [tab_name] 
    130126 
    131127        #print "CURRENT dict: ", self.dataToFitTab 
     
    173169        Given name of the fitting tab - close it 
    174170        """ 
    175         for tab_index in xrange(len(self.tabs)): 
     171        for tab_index in range(len(self.tabs)): 
    176172            if self.tabText(tab_index) == tab_name: 
    177173                self.tabCloses(tab_index) 
     
    185181            return 
    186182        for index_to_delete in index_list: 
    187             if index_to_delete in self.dataToFitTab.keys(): 
    188                 for tab_name in self.dataToFitTab[index_to_delete]: 
     183            index_to_delete_str = str(index_to_delete) 
     184            if index_to_delete_str in list(self.dataToFitTab.keys()): 
     185                for tab_name in self.dataToFitTab[index_to_delete_str]: 
    189186                    # delete tab #index after corresponding data got removed 
    190187                    self.closeTabByName(tab_name) 
    191                 self.dataToFitTab.pop(index_to_delete) 
     188                self.dataToFitTab.pop(index_to_delete_str) 
    192189 
    193190        #print "CURRENT dict: ", self.dataToFitTab 
     
    209206        if not isinstance(data_item, list): 
    210207            msg = "Incorrect type passed to the Fitting Perspective" 
    211             raise AttributeError, msg 
     208            raise AttributeError(msg) 
    212209 
    213210        if not isinstance(data_item[0], QtGui.QStandardItem): 
    214211            msg = "Incorrect type passed to the Fitting Perspective" 
    215             raise AttributeError, msg 
     212            raise AttributeError(msg) 
    216213 
    217214        items = [data_item] if is_batch else data_item 
     
    220217            # Find the first unassigned tab. 
    221218            # If none, open a new tab. 
    222             available_tabs = list(map(lambda tab: tab.acceptsData(), self.tabs)) 
     219            available_tabs = list([tab.acceptsData() for tab in self.tabs]) 
    223220 
    224221            if numpy.any(available_tabs): 
  • src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py

    • Property mode changed from 100644 to 100755
    rd0dfcb2 rb3e8629  
    4444    Returns a list of all multi-shell parameters in 'model' 
    4545    """ 
    46     return list(filter(lambda par: "[" in par.name, model.iq_parameters)) 
     46    return list([par for par in model.iq_parameters if "[" in par.name]) 
    4747 
    4848def getMultiplicity(model): 
     
    156156    """ 
    157157    for i, item in enumerate(model_header_captions): 
    158         model.setHeaderData(i, QtCore.Qt.Horizontal, QtCore.QVariant(item)) 
     158        #model.setHeaderData(i, QtCore.Qt.Horizontal, QtCore.QVariant(item)) 
     159        model.setHeaderData(i, QtCore.Qt.Horizontal, item) 
    159160 
    160161    model.header_tooltips = model_header_tooltips 
     
    167168    model_header_error_captions.insert(2, header_error_caption) 
    168169    for i, item in enumerate(model_header_error_captions): 
    169         model.setHeaderData(i, QtCore.Qt.Horizontal, QtCore.QVariant(item)) 
     170        model.setHeaderData(i, QtCore.Qt.Horizontal, item) 
    170171 
    171172    model_header_error_tooltips = model_header_tooltips 
     
    178179    """ 
    179180    for i, item in enumerate(poly_header_captions): 
    180         model.setHeaderData(i, QtCore.Qt.Horizontal, QtCore.QVariant(item)) 
     181        model.setHeaderData(i, QtCore.Qt.Horizontal, item) 
    181182 
    182183    model.header_tooltips = poly_header_tooltips 
     
    190191    poly_header_error_captions.insert(2, header_error_caption) 
    191192    for i, item in enumerate(poly_header_error_captions): 
    192         model.setHeaderData(i, QtCore.Qt.Horizontal, QtCore.QVariant(item)) 
     193        model.setHeaderData(i, QtCore.Qt.Horizontal, item) 
    193194 
    194195    poly_header_error_tooltips = poly_header_tooltips 
     
    202203    multishell_parameters = getIterParams(parameters) 
    203204 
    204     for i in xrange(index): 
     205    for i in range(index): 
    205206        for par in multishell_parameters: 
    206207            # Create the name: <param>[<i>], e.g. "sld1" for parameter "sld[n]" 
     
    396397 
    397398def binary_encode(i, digits): 
    398     return [i >> d & 1 for d in xrange(digits)] 
     399    return [i >> d & 1 for d in range(digits)] 
    399400 
    400401def getWeight(data, is2d, flag=None): 
  • 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 
  • src/sas/qtgui/Perspectives/Fitting/ModelThread.py

    r6964d44 rb3e8629  
    6565        if self.data is None: 
    6666            msg = "Compute Calc2D receive data = %s.\n" % str(self.data) 
    67             raise ValueError, msg 
     67            raise ValueError(msg) 
    6868 
    6969        # Define matrix where data will be plotted 
  • src/sas/qtgui/Perspectives/Fitting/ModelUtilities.py

    r125c4be rb3e8629  
    22    Utilities to manage models 
    33""" 
    4 from __future__ import print_function 
     4 
    55 
    66import traceback 
     
    6868    except: 
    6969        msg = "Plugin %s error in __init__ \n\t: %s %s\n" % (str(name), 
    70                                                              str(sys.exc_type), 
     70                                                             str(sys.exc_info()[0]), 
    7171                                                             sys.exc_info()[1]) 
    7272        plugin_log(msg) 
     
    7878        except: 
    7979            msg = "Plugin %s: error writing function \n\t :%s %s\n " % \ 
    80                     (str(name), str(sys.exc_type), sys.exc_info()[1]) 
     80                    (str(name), str(sys.exc_info()[0]), sys.exc_info()[1]) 
    8181            plugin_log(msg) 
    8282            return None 
     
    138138    Class to check for problems with specific values 
    139139    """ 
    140     def __nonzero__(self): 
     140    def __bool__(self): 
    141141        type, value, tb = sys.exc_info() 
    142142        if type is not None and issubclass(type, py_compile.PyCompileError): 
    143143            print("Problem with", repr(value)) 
    144             raise type, value, tb 
     144            raise type(value).with_traceback(tb) 
    145145        return 1 
    146146 
     
    211211 
    212212        """ 
    213         if name not in self.mydict.keys(): 
     213        if name not in list(self.mydict.keys()): 
    214214            self.reset_list(name, mylist) 
    215215 
     
    292292        #Looking for plugins 
    293293        self.stored_plugins = self.findModels() 
    294         self.plugins = self.stored_plugins.values() 
    295         for name, plug in self.stored_plugins.iteritems(): 
     294        self.plugins = list(self.stored_plugins.values()) 
     295        for name, plug in self.stored_plugins.items(): 
    296296            self.model_dictionary[name] = plug 
    297297         
     
    322322        new_plugins = self.findModels() 
    323323        if len(new_plugins) > 0: 
    324             for name, plug in  new_plugins.iteritems(): 
    325                 if name not in self.stored_plugins.keys(): 
     324            for name, plug in  new_plugins.items(): 
     325                if name not in list(self.stored_plugins.keys()): 
    326326                    self.stored_plugins[name] = plug 
    327327                    self.plugins.append(plug) 
     
    338338        self.plugins = [] 
    339339        new_plugins = _find_models() 
    340         for name, plug in  new_plugins.iteritems(): 
    341             for stored_name, stored_plug in self.stored_plugins.iteritems(): 
     340        for name, plug in  new_plugins.items(): 
     341            for stored_name, stored_plug in self.stored_plugins.items(): 
    342342                if name == stored_name: 
    343343                    del self.stored_plugins[name] 
     
    358358 
    359359        """ 
    360         if int(evt.GetId()) in self.form_factor_dict.keys(): 
     360        if int(evt.GetId()) in list(self.form_factor_dict.keys()): 
    361361            from sasmodels.sasview_model import MultiplicationModel 
    362362            self.model_dictionary[MultiplicationModel.__name__] = MultiplicationModel 
     
    417417    __modelmanager = ModelManagerBase() 
    418418    cat_model_list = [__modelmanager.model_dictionary[model_name] for model_name \ 
    419                       in __modelmanager.model_dictionary.keys() \ 
    420                       if model_name not in __modelmanager.stored_plugins.keys()] 
     419                      in list(__modelmanager.model_dictionary.keys()) \ 
     420                      if model_name not in list(__modelmanager.stored_plugins.keys())] 
    421421 
    422422    CategoryInstaller.check_install(model_list=cat_model_list) 
  • src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py

    r457d961 rb3e8629  
    9696        """ 
    9797        self.model = QtGui.QStandardItemModel() 
    98         for model_item in xrange(len(MODEL)): 
     98        for model_item in range(len(MODEL)): 
    9999            self.model.setItem(model_item, QtGui.QStandardItem()) 
    100100        # Attach slot 
  • src/sas/qtgui/Perspectives/Fitting/SmearingWidget.py

    • Property mode changed from 100644 to 100755
    rdc5ef15 rb3e8629  
    6565        """ 
    6666        self.model = QtGui.QStandardItemModel() 
    67         for model_item in xrange(len(MODEL)): 
     67        for model_item in range(len(MODEL)): 
    6868            self.model.setItem(model_item, QtGui.QStandardItem()) 
    6969        # Attach slot 
  • src/sas/qtgui/Perspectives/Invariant/InvariantDetails.py

    • Property mode changed from 100644 to 100755
    r28cda69 rb3e8629  
    55 
    66# local 
    7 from UI.InvariantDetailsUI import Ui_Dialog 
    8 from InvariantUtils import WIDGETS 
     7from .UI.InvariantDetailsUI import Ui_Dialog 
     8from .InvariantUtils import WIDGETS 
    99 
    1010class DetailsDialog(QtGui.QDialog, Ui_Dialog): 
  • src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py

    • Property mode changed from 100644 to 100755
    r457d961 rb3e8629  
    1515 
    1616# local 
    17 from UI.TabbedInvariantUI import Ui_tabbedInvariantUI 
    18 from InvariantDetails import DetailsDialog 
    19 from InvariantUtils import WIDGETS 
     17from .UI.TabbedInvariantUI import Ui_tabbedInvariantUI 
     18from .InvariantDetails import DetailsDialog 
     19from .InvariantUtils import WIDGETS 
    2020 
    2121# The minimum q-value to be used when extrapolating 
     
    551551        if not isinstance(data_item, list): 
    552552            msg = "Incorrect type passed to the Invariant Perspective" 
    553             raise AttributeError, msg 
     553            raise AttributeError(msg) 
    554554 
    555555        if not isinstance(data_item[0], QtGui.QStandardItem): 
    556556            msg = "Incorrect type passed to the Invariant Perspective" 
    557             raise AttributeError, msg 
     557            raise AttributeError(msg) 
    558558 
    559559        self._model_item = data_item[0] 
     
    631631                    self.calculateInvariant() 
    632632                except: 
    633                     msg = "Invariant Set_data: " + str(sys.exc_value) 
     633                    msg = "Invariant Set_data: " + str(sys.exc_info()[1]) 
    634634                    #wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 
    635635        else: 
  • src/sas/qtgui/Perspectives/Invariant/InvariantUtils.py

    rf721030 rb3e8629  
    11def enum(*sequential, **named): 
    2     enums = dict(zip(sequential, range(len(sequential))), **named) 
     2    enums = dict(list(zip(sequential, list(range(len(sequential))))), **named) 
    33    return type('Enum', (), enums) 
    44 
  • src/sas/qtgui/Perspectives/__init__.py

    • Property mode changed from 100644 to 100755
    r7adc2a8 rb3e8629  
    22# When adding a new perspective, this dictionary needs to be updated 
    33 
    4 from Fitting.FittingPerspective import FittingWindow 
    5 from Invariant.InvariantPerspective import InvariantWindow 
     4from .Fitting.FittingPerspective import FittingWindow 
     5from .Invariant.InvariantPerspective import InvariantWindow 
    66 
    77PERSPECTIVES = { 
  • src/sas/qtgui/Plotting/Arrow3D.py

    rfef38e8 rb3e8629  
    5959            return 
    6060        xs3d, ys3d, zs3d = self._verts3d 
    61         for i in xrange(len(xs3d)): 
     61        for i in range(len(xs3d)): 
    6262            xs, ys, _ = proj3d.proj_transform(xs3d[i], ys3d[i], zs3d[i], renderer.M) 
    6363            self.set_positions((xs[0], ys[0]), (xs[1], ys[1])) 
  • src/sas/qtgui/Plotting/Binder.py

    rdc5ef15 rb3e8629  
    2424        return self.artist is not other.artist 
    2525 
    26     def __nonzero__(self): 
     26    def __bool__(self): 
    2727        return self.artist is not None 
    2828 
     
    6161            ] 
    6262        except: 
    63             print "bypassing scroll_event: wrong matplotlib version" 
     63            print("bypassing scroll_event: wrong matplotlib version") 
    6464            self._connections = [ 
    6565                canvas.mpl_connect('motion_notify_event', self._onMotion), 
     
    121121            for cid in self._connections: self.canvas.mpl_disconnect(cid) 
    122122        except: 
    123             logging.error("Error disconnection canvas: %s" % sys.exc_value) 
     123            logging.error("Error disconnection canvas: %s" % sys.exc_info()[1]) 
    124124        self._connections = [] 
    125125 
     
    185185        # Check that the trigger is valid 
    186186        if trigger not in self._actions: 
    187             raise ValueError, "%s invalid --- valid triggers are %s"\ 
    188                  % (trigger, ", ".join(self.events)) 
     187            raise ValueError("%s invalid --- valid triggers are %s"\ 
     188                 % (trigger, ", ".join(self.events))) 
    189189 
    190190        # Register the trigger callback 
     
    201201        """ 
    202202        if action not in self.events: 
    203             raise ValueError, "Trigger expects " + ", ".join(self.events) 
     203            raise ValueError("Trigger expects " + ", ".join(self.events)) 
    204204 
    205205        # Tag the event with modifiers 
  • src/sas/qtgui/Plotting/ColorMap.py

    • Property mode changed from 100644 to 100755
    rdc5ef15 rb3e8629  
    1313from sas.qtgui.Plotting.PlotterData import Data2D 
    1414from sas.qtgui.Utilities.GuiUtils import formatNumber 
    15 from rangeSlider import RangeSlider 
     15from .rangeSlider import RangeSlider 
    1616 
    1717DEFAULT_MAP = 'jet' 
  • src/sas/qtgui/Plotting/ConvertUnits.py

    r749b715 rb3e8629  
    4242                            unit = toks[0] + "^{" + str(powerer) + "}" 
    4343                else: 
    44                     raise ValueError, "missing } in unit expression" 
     44                    raise ValueError("missing } in unit expression") 
    4545        else:  # no powerer 
    4646            if  power != 1: 
    4747                unit = "(" + unit + ")" + "^{" + str(power) + "}" 
    4848    else: 
    49         raise ValueError, "empty unit ,enter a powerer different from zero" 
     49        raise ValueError("empty unit ,enter a powerer different from zero") 
    5050    return unit 
    5151 
     
    6868    unit8 = "m/s^{4}"  #         x^2               (m/s^{4})^{2} 
    6969 
    70     print "this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1)) 
    71     print "this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2)) 
    72     print "this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3)) 
    73     print "this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4)) 
    74     print "this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5)) 
    75     print "this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6)) 
    76     print "this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7)) 
    77     print "this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8)) 
    78     print "this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9)) 
     70    print("this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1))) 
     71    print("this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2))) 
     72    print("this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3))) 
     73    print("this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4))) 
     74    print("this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5))) 
     75    print("this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6))) 
     76    print("this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7))) 
     77    print("this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8))) 
     78    print("this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9))) 
    7979 
    8080 
  • src/sas/qtgui/Plotting/DataTransform.py

    r749b715 rb3e8629  
    2424    """ 
    2525    if not x > 0: 
    26         raise ValueError, "Transformation only accepts positive values." 
     26        raise ValueError("Transformation only accepts positive values.") 
    2727    else: 
    2828        return x 
     
    5050    """ 
    5151    if not x >= 0: 
    52         raise ValueError, "square root of a negative value " 
     52        raise ValueError("square root of a negative value ") 
    5353    else: 
    5454        return math.sqrt(x) 
     
    7676    """ 
    7777    if not x >= 0: 
    78         raise ValueError, "double square root of a negative value " 
     78        raise ValueError("double square root of a negative value ") 
    7979    else: 
    8080        return math.sqrt(math.sqrt(x)) 
     
    9090    """ 
    9191    if not x > 0: 
    92         raise ValueError, "Log(x)of a negative value " 
     92        raise ValueError("Log(x)of a negative value ") 
    9393    else: 
    9494        return math.log(x) 
     
    100100        return 1 / x 
    101101    else: 
    102         raise ValueError, "cannot divide by zero" 
     102        raise ValueError("cannot divide by zero") 
    103103 
    104104 
     
    109109        return 1 / math.sqrt(y) 
    110110    else: 
    111         raise ValueError, "transform.toOneOverSqrtX: cannot be computed" 
     111        raise ValueError("transform.toOneOverSqrtX: cannot be computed") 
    112112 
    113113 
     
    118118        return math.log(y * (x ** 2)) 
    119119    else: 
    120         raise ValueError, "transform.toLogYX2: cannot be computed" 
     120        raise ValueError("transform.toLogYX2: cannot be computed") 
    121121 
    122122 
     
    127127        return math.log(math.pow(x, 4) * y) 
    128128    else: 
    129         raise ValueError, "transform.toLogYX4: input error" 
     129        raise ValueError("transform.toLogYX4: input error") 
    130130 
    131131 
     
    149149    """ 
    150150    if not (x * y) > 0: 
    151         raise ValueError, "Log(X*Y)of a negative value " 
     151        raise ValueError("Log(X*Y)of a negative value ") 
    152152    else: 
    153153        return math.log(x * y) 
     
    211211    else: 
    212212        msg = "transform.errFromX2: can't compute error of negative x" 
    213         raise ValueError, msg 
     213        raise ValueError(msg) 
    214214 
    215215 
     
    245245    else: 
    246246        msg = "transform.errFromX4: can't compute error of negative x" 
    247         raise ValueError, msg 
     247        raise ValueError(msg) 
    248248 
    249249 
     
    264264        msg = "Transformation does not accept" 
    265265        msg += " point that are consistent with zero." 
    266         raise ValueError, msg 
     266        raise ValueError(msg) 
    267267    if x != 0: 
    268268        dx = dx / (x * math.log(10)) 
    269269    else: 
    270         raise ValueError, "errToLogX: divide by zero" 
     270        raise ValueError("errToLogX: divide by zero") 
    271271    return dx 
    272272 
     
    287287        dx = dx / x 
    288288    else: 
    289         raise ValueError, "errToLogX: divide by zero" 
     289        raise ValueError("errToLogX: divide by zero") 
    290290    return dx 
    291291 
     
    312312        msg = "Transformation does not accept point " 
    313313        msg += " that are consistent with zero." 
    314         raise ValueError, msg 
     314        raise ValueError(msg) 
    315315    if x != 0 and y != 0: 
    316316        if dx == None: 
     
    320320        err = (dx / x) ** 2 + (dy / y) ** 2 
    321321    else: 
    322         raise ValueError, "cannot compute this error" 
     322        raise ValueError("cannot compute this error") 
    323323 
    324324    return math.sqrt(math.fabs(err)) 
     
    335335        msg = "Transformation does not accept point" 
    336336        msg += " that are consistent with zero." 
    337         raise ValueError, msg 
     337        raise ValueError(msg) 
    338338    if x > 0 and y > 0: 
    339339        if dx == None: 
     
    343343        err = (2.0 * dx / x) ** 2 + (dy / y) ** 2 
    344344    else: 
    345         raise ValueError, "cannot compute this error" 
     345        raise ValueError("cannot compute this error") 
    346346    return math.sqrt(math.fabs(err)) 
    347347 
     
    357357        err = dx / x ** 2 
    358358    else: 
    359         raise ValueError, "Cannot compute this error" 
     359        raise ValueError("Cannot compute this error") 
    360360    return math.fabs(err) 
    361361 
     
    371371        err = -1 / 2 * math.pow(x, -3.0 / 2.0) * dx 
    372372    else: 
    373         raise ValueError, "Cannot compute this error" 
     373        raise ValueError("Cannot compute this error") 
    374374    return math.fabs(err) 
    375375 
     
    387387        msg = "Transformation does not accept point " 
    388388        msg += " that are consistent with zero." 
    389         raise ValueError, msg 
     389        raise ValueError(msg) 
    390390    if dx == None: 
    391391        dx = 0 
  • src/sas/qtgui/Plotting/Fittings.py

    • Property mode changed from 100644 to 100755
    radc49fc rb3e8629  
    9797    # Testing implementation 
    9898    # Fit a Line model 
    99     from LineModel import LineModel 
     99    from .LineModel import LineModel 
    100100    line = LineModel() 
    101101    cstA = Parameter(line, 'A', event.cstA) 
     
    104104    chisqr, out, cov = sasfit(line, [cstA, cstB], event.x, y, 0) 
    105105    # print "Output parameters:", out 
    106     print "The right answer is [70.0, 1.0]" 
    107     print chisqr, out, cov 
     106    print("The right answer is [70.0, 1.0]") 
     107    print(chisqr, out, cov) 
    108108 
  • src/sas/qtgui/Plotting/LineModel.py

    r749b715 rb3e8629  
    8181        elif x.__class__.__name__ == 'tuple': 
    8282            msg = "Tuples are not allowed as input to BaseComponent models" 
    83             raise ValueError, msg 
     83            raise ValueError(msg) 
    8484        else: 
    8585            return self._line(x) 
     
    103103        elif x.__class__.__name__ == 'tuple': 
    104104            msg = "Tuples are not allowed as input to BaseComponent models" 
    105             raise ValueError, msg 
     105            raise ValueError(msg) 
    106106        else: 
    107107            return self._line(x) 
  • src/sas/qtgui/Plotting/LinearFit.py

    • Property mode changed from 100644 to 100755
    rdc5ef15 rb3e8629  
    7979        Overwrite default fit range label to correspond to actual unit 
    8080        """ 
    81         assert(isinstance(label, basestring)) 
     81        assert(isinstance(label, str)) 
    8282        self.lblRange.setText(label) 
    8383 
     
    195195                         for i in range(len(x)) if x[i] >= xmin_check] 
    196196            else: 
    197                 tempy = map(numpy.log10, y) 
    198                 tempdy = map(lambda t1,t2:DataTransform.errToLogX(t1,0,t2,0),y,dy) 
     197                tempy = list(map(numpy.log10, y)) 
     198                tempdy = list(map(lambda t1,t2:DataTransform.errToLogX(t1,0,t2,0),y,dy)) 
    199199        else: 
    200200            tempy = y 
  • src/sas/qtgui/Plotting/PlotHelper.py

    • Property mode changed from 100644 to 100755
    r83eb5208 rb3e8629  
    3535    Returns a list of IDs for all currently active plots 
    3636    """ 
    37     return this._plots.keys() 
     37    return list(this._plots.keys()) 
    3838 
    3939def plotById(plot_id): 
     
    4848    """ 
    4949    plot_id = None 
    50     for key in this._plots.keys(): 
     50    for key in list(this._plots.keys()): 
    5151        if this._plots[key] == plot: 
    5252            plot_id = key 
  • src/sas/qtgui/Plotting/PlotProperties.py

    • Property mode changed from 100644 to 100755
    rcd2cc745 rb3e8629  
    2626 
    2727        # Fill out the color combobox 
    28         self.cbColor.addItems(COLORS.keys()[:-1]) 
     28        self.cbColor.addItems(list(COLORS.keys())[:-1]) 
    2929        # data1d.custom_color can now be a simple integer, 
    3030        # specifying COLORS dict index or a string containing 
     
    3434        else: 
    3535            # Need the Custom entry here. "Custom" is always last. 
    36             self.cbColor.addItems([COLORS.keys()[-1]]) 
    37             self.cbColor.setCurrentIndex(COLORS.keys().index("Custom")) 
     36            self.cbColor.addItems([list(COLORS.keys())[-1]]) 
     37            self.cbColor.setCurrentIndex(list(COLORS.keys()).index("Custom")) 
    3838 
    3939        # Fill out the marker combobox 
    40         self.cbShape.addItems(SHAPES.keys()) 
     40        self.cbShape.addItems(list(SHAPES.keys())) 
    4141        try: 
    4242            self.cbShape.setCurrentIndex(self._marker) 
     
    8383            # Add Custom to the color combo box 
    8484            self.cbColor.addItems(["Custom"]) 
    85             self.cbColor.setCurrentIndex(COLORS.keys().index("Custom")) 
     85            self.cbColor.setCurrentIndex(list(COLORS.keys()).index("Custom")) 
    8686            # unblock currentIndexChanged 
    8787            self.cbColor.blockSignals(False) 
  • src/sas/qtgui/Plotting/PlotUtilities.py

    • Property mode changed from 100644 to 100755
    r83eb5208 rb3e8629  
    273273        # Check if it's within the range 
    274274        if 0 <= color <=6: 
    275             color = COLORS.values()[color] 
     275            color = list(COLORS.values())[color] 
    276276    # Check if it's an RGB string 
    277277    elif isinstance(color, str): 
  • src/sas/qtgui/Plotting/Plottables.py

    rdc5ef15 rb3e8629  
    239239        selected_color = None 
    240240        selected_plottable = None 
    241         for p in self.plottables.keys(): 
     241        for p in list(self.plottables.keys()): 
    242242            if plottable.id == p.id: 
    243243                selected_plottable = p 
     
    384384 
    385385        """ 
    386         raise NotImplemented, "Not a valid transform" 
     386        raise NotImplemented("Not a valid transform") 
    387387 
    388388    # Related issues 
     
    512512                label_dict[collection[0]] = basename 
    513513            else: 
    514                 for i in xrange(len(collection)): 
     514                for i in range(len(collection)): 
    515515                    label_dict[collection[i]] = "%s %d" % (basename, i) 
    516516        return label_dict 
     
    684684                msg = "Plottable.View: Given x and dx are not" 
    685685                msg += " of the same length" 
    686                 raise ValueError, msg 
     686                raise ValueError(msg) 
    687687            # Check length of y array 
    688688            if not len(y) == len(x): 
    689689                msg = "Plottable.View: Given y " 
    690690                msg += "and x are not of the same length" 
    691                 raise ValueError, msg 
     691                raise ValueError(msg) 
    692692 
    693693            if not dy is None and not len(dy) == 0 and not len(y) == len(dy): 
    694694                msg = "Plottable.View: Given y and dy are not of the same " 
    695695                msg += "length: len(y)=%s, len(dy)=%s" % (len(y), len(dy)) 
    696                 raise ValueError, msg 
     696                raise ValueError(msg) 
    697697            self.x = [] 
    698698            self.y = [] 
     
    729729                msg = "Plottable.View: transformed x " 
    730730                msg += "and y are not of the same length" 
    731                 raise ValueError, msg 
     731                raise ValueError(msg) 
    732732            if has_err_x and not (len(self.x) == len(self.dx)): 
    733733                msg = "Plottable.View: transformed x and dx" 
    734734                msg += " are not of the same length" 
    735                 raise ValueError, msg 
     735                raise ValueError(msg) 
    736736            if has_err_y and not (len(self.y) == len(self.dy)): 
    737737                msg = "Plottable.View: transformed y" 
    738738                msg += " and dy are not of the same length" 
    739                 raise ValueError, msg 
     739                raise ValueError(msg) 
    740740            # Check that negative values are not plot on x and y axis for 
    741741            # log10 transformation 
     
    809809                except: 
    810810                    logging.error("check_data_logX: skipping point x %g", self.x[i]) 
    811                     logging.error(sys.exc_value) 
     811                    logging.error(sys.exc_info()[1]) 
    812812            self.x = tempx 
    813813            self.y = tempy 
     
    839839                except: 
    840840                    logging.error("check_data_logY: skipping point %g", self.y[i]) 
    841                     logging.error(sys.exc_value) 
     841                    logging.error(sys.exc_info()[1]) 
    842842 
    843843            self.x = tempx 
     
    11011101        Plottable.__init__(self) 
    11021102        msg = "Theory1D is no longer supported, please use Data1D and change symbol.\n" 
    1103         raise DeprecationWarning, msg 
     1103        raise DeprecationWarning(msg) 
    11041104 
    11051105class PlottableFit1D(Plottable): 
  • src/sas/qtgui/Plotting/Plotter.py

    • Property mode changed from 100644 to 100755
    r749b715 rb3e8629  
    9090                marker = PlotUtilities.SHAPES[marker] 
    9191            except KeyError: 
    92                 marker = PlotUtilities.SHAPES.values()[marker] 
     92                marker = list(PlotUtilities.SHAPES.values())[marker] 
    9393 
    9494        assert marker is not None 
     
    206206        Adds operations on all plotted sets of data to the context menu 
    207207        """ 
    208         for id in self.plot_dict.keys(): 
     208        for id in list(self.plot_dict.keys()): 
    209209            plot = self.plot_dict[id] 
    210210 
     
    391391        Deletes the selected plot from the chart 
    392392        """ 
    393         if id not in self.plot_dict.keys(): 
     393        if id not in list(self.plot_dict.keys()): 
    394394            return 
    395395 
     
    482482        """ 
    483483        # Transform all the plots on the chart 
    484         for id in self.plot_dict.keys(): 
     484        for id in list(self.plot_dict.keys()): 
    485485            current_plot = self.plot_dict[id] 
    486486            if current_plot.id == "fit": 
  • src/sas/qtgui/Plotting/SlicerModel.py

    • Property mode changed from 100644 to 100755
    r83eb5208 rb3e8629  
    1919        self._model.removeRows( 0, self._model.rowCount() ) 
    2020        # Crete/overwrite model items 
    21         for parameter in parameters.keys(): 
     21        for parameter in list(parameters.keys()): 
    2222            item1 = QtGui.QStandardItem(parameter) 
    2323            item2 = QtGui.QStandardItem(GuiUtils.formatNumber(parameters[parameter])) 
  • src/sas/qtgui/Plotting/Slicers/AnnulusSlicer.py

    rdc5ef15 rb3e8629  
    44 
    55import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    6 from BaseInteractor import BaseInteractor 
     6from .BaseInteractor import BaseInteractor 
    77from sas.qtgui.Plotting.PlotterData import Data1D 
    88from sas.qtgui.Utilities.GuiUtils import formatNumber 
  • src/sas/qtgui/Plotting/Slicers/Arc.py

    r749b715 rb3e8629  
    44import math 
    55 
    6 from BaseInteractor import BaseInteractor 
     6from .BaseInteractor import BaseInteractor 
    77 
    88class ArcInteractor(BaseInteractor): 
  • src/sas/qtgui/Plotting/Slicers/AzimutSlicer.py

    rdc5ef15 rb3e8629  
    55# 
    66import math 
    7 from BaseInteractor import BaseInteractor 
     7from .BaseInteractor import BaseInteractor 
    88 
    99class SectorInteractor(BaseInteractor): 
     
    2626 
    2727        # Inner circle 
    28         from Arc import ArcInteractor 
     28        from .Arc import ArcInteractor 
    2929        self.inner_circle = ArcInteractor(self, self.base.subplot, 
    3030                                          zorder=zorder, 
  • src/sas/qtgui/Plotting/Slicers/BoxSlicer.py

    rdc5ef15 rb3e8629  
    33from PyQt4 import QtCore 
    44 
    5 from BaseInteractor import BaseInteractor 
     5from .BaseInteractor import BaseInteractor 
    66from sas.qtgui.Plotting.PlotterData import Data1D 
    77import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     
    136136            if new_slab is None: 
    137137                msg = "post data:cannot average , averager is empty" 
    138                 raise ValueError, msg 
     138                raise ValueError(msg) 
    139139            self.averager = new_slab 
    140140        if self.direction == "X": 
     
    152152        else: 
    153153            msg = "post data:no Box Average direction was supplied" 
    154             raise ValueError, msg 
     154            raise ValueError(msg) 
    155155        # # Average data2D given Qx or Qy 
    156156        box = self.averager(x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max, 
  • src/sas/qtgui/Plotting/Slicers/BoxSum.py

    rdc5ef15 rb3e8629  
    88from sas.qtgui.Utilities.GuiUtils import formatNumber 
    99 
    10 from BaseInteractor import BaseInteractor 
     10from .BaseInteractor import BaseInteractor 
    1111from sas.sascalc.dataloader.manipulations import Boxavg 
    1212from sas.sascalc.dataloader.manipulations import Boxsum 
  • src/sas/qtgui/Plotting/Slicers/SectorSlicer.py

    rdc5ef15 rb3e8629  
    66from PyQt4 import QtCore 
    77 
    8 from BaseInteractor import BaseInteractor 
     8from .BaseInteractor import BaseInteractor 
    99from sas.qtgui.Plotting.PlotterData import Data1D 
    1010import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     
    230230            msg = "Phi left and phi right are different" 
    231231            msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 
    232             raise ValueError, msg 
     232            raise ValueError(msg) 
    233233        params["Phi [deg]"] = self.main_line.theta * 180 / numpy.pi 
    234234        params["Delta_Phi [deg]"] = numpy.fabs(self.left_line.phi * 180 / numpy.pi) 
  • src/sas/qtgui/Utilities/CategoryInstaller.py

    r125c4be rb3e8629  
    103103                master_category_dict[category].append(\ 
    104104                    (model, model_enabled_dict[model])) 
    105         return OrderedDict(sorted(master_category_dict.items(), key=lambda t: t[0])) 
     105        return OrderedDict(sorted(list(master_category_dict.items()), key=lambda t: t[0])) 
    106106 
    107107    @staticmethod 
     
    126126        """ 
    127127        _model_dict = { model.name: model for model in model_list} 
    128         _model_list = _model_dict.keys() 
     128        _model_list = list(_model_dict.keys()) 
    129129 
    130130        serialized_file = None 
     
    143143        add_list = _model_list 
    144144        del_name = False 
    145         for cat in master_category_dict.keys(): 
     145        for cat in list(master_category_dict.keys()): 
    146146            for ind in range(len(master_category_dict[cat])): 
    147147                model_name, enabled = master_category_dict[cat][ind] 
     
    152152                        model_enabled_dict.pop(model_name) 
    153153                    except: 
    154                         logging.error("CategoryInstaller: %s", sys.exc_value) 
     154                        logging.error("CategoryInstaller: %s", sys.exc_info()[1]) 
    155155                else: 
    156156                    add_list.remove(model_name) 
  • src/sas/qtgui/Utilities/ConnectionProxy.py

    rdc5ef15 rb3e8629  
    11#!/usr/bin/env python 
    22# -*- coding: utf-8 -*- 
    3 import urllib2 
     3import urllib.request, urllib.error, urllib.parse 
    44import sys 
    55import json 
     
    3333        if sys.platform == 'win32': 
    3434            try: 
    35                 import _winreg as winreg  # used from python 2.0-2.6 
     35                import winreg as winreg  # used from python 2.0-2.6 
    3636            except: 
    3737                import winreg  # used from python 2.7 onwards 
     
    4545                this_name, this_val, this_type = winreg.EnumValue(net, i) 
    4646                subkeys[this_name] = this_val 
    47             if 'AutoConfigURL' in subkeys.keys() and len(subkeys['AutoConfigURL']) > 0: 
     47            if 'AutoConfigURL' in list(subkeys.keys()) and len(subkeys['AutoConfigURL']) > 0: 
    4848                pac_files.append(subkeys['AutoConfigURL']) 
    4949        elif sys.platform == 'darwin': 
     
    5353            networks = sys_prefs['NetworkServices'] 
    5454            # loop through each possible network (e.g. Ethernet, Airport...) 
    55             for network in networks.items(): 
     55            for network in list(networks.items()): 
    5656                # the first part is a long identifier 
    5757                net_key, network = network 
    58                 if 'ProxyAutoConfigURLString' in network['Proxies'].keys(): 
     58                if 'ProxyAutoConfigURLString' in list(network['Proxies'].keys()): 
    5959                    pac_files.append( 
    6060                        network['Proxies']['ProxyAutoConfigURLString']) 
     
    7373            logging.debug('Trying pac file (%s)...' % this_pac_url) 
    7474            try: 
    75                 response = urllib2.urlopen( 
     75                response = urllib.request.urlopen( 
    7676                    this_pac_url, timeout=self.timeout) 
    7777                logging.debug('Succeeded (%s)...' % this_pac_url) 
     
    101101            # information is retrieved from the OS X System Configuration 
    102102            # Framework. 
    103             proxy = urllib2.ProxyHandler() 
     103            proxy = urllib.request.ProxyHandler() 
    104104        else: 
    105105            # If proxies is given, it must be a dictionary mapping protocol names to 
    106106            # URLs of proxies. 
    107             proxy = urllib2.ProxyHandler(proxy_dic) 
    108         opener = urllib2.build_opener(proxy) 
    109         urllib2.install_opener(opener) 
     107            proxy = urllib.request.ProxyHandler(proxy_dic) 
     108        opener = urllib.request.build_opener(proxy) 
     109        urllib.request.install_opener(opener) 
    110110 
    111111    def connect(self): 
     
    114114        @return: response object from urllib2.urlopen 
    115115        ''' 
    116         req = urllib2.Request(self.url) 
     116        req = urllib.request.Request(self.url) 
    117117        response = None 
    118118        try: 
    119119            logging.debug("Trying Direct connection to %s..."%self.url) 
    120             response = urllib2.urlopen(req, timeout=self.timeout) 
    121         except Exception, e: 
     120            response = urllib.request.urlopen(req, timeout=self.timeout) 
     121        except Exception as e: 
    122122            logging.debug("Failed!") 
    123123            logging.debug(e) 
     
    125125                logging.debug("Trying to use system proxy if it exists...") 
    126126                self._set_proxy() 
    127                 response = urllib2.urlopen(req, timeout=self.timeout) 
    128             except Exception, e: 
     127                response = urllib.request.urlopen(req, timeout=self.timeout) 
     128            except Exception as e: 
    129129                logging.debug("Failed!") 
    130130                logging.debug(e) 
     
    135135                        logging.debug("Trying to use the proxy %s found in proxy.pac configuration"%proxy) 
    136136                        self._set_proxy(proxy) 
    137                         response = urllib2.urlopen(req, timeout=self.timeout) 
    138                     except Exception, e: 
     137                        response = urllib.request.urlopen(req, timeout=self.timeout) 
     138                    except Exception as e: 
    139139                        logging.debug("Failed!") 
    140140                        logging.debug(e) 
     
    151151    response = c.connect() 
    152152    if response is not None: 
    153         print 50 * '-' 
     153        print(50 * '-') 
    154154        content = json.loads(response.read().strip()) 
    155155        pprint(content) 
  • src/sas/qtgui/Utilities/GuiUtils.py

    • Property mode changed from 100644 to 100755
    r88e1f57 rb3e8629  
    99import warnings 
    1010import webbrowser 
    11 import urlparse 
     11import urllib.parse 
    1212 
    1313warnings.simplefilter("ignore") 
     
    8686        #logging.error("Error loading %s/%s: %s" % (path, confg_file, sys.exc_value)) 
    8787    except ValueError: 
    88         print "Value error" 
     88        print("Value error") 
    8989        pass 
    9090    finally: 
     
    242242    """ 
    243243    assert isinstance(item, QtGui.QStandardItem) 
    244     assert isinstance(update_data, QtCore.QVariant) 
    245     py_update_data = update_data.toPyObject() 
     244    #assert isinstance(update_data, QtCore.QVariant) 
     245    #py_update_data = update_data.toPyObject() 
     246    py_update_data = update_data 
    246247 
    247248    # Check if data with the same ID is already present 
     
    249250        plot_item = item.child(index) 
    250251        if plot_item.isCheckable(): 
    251             plot_data = plot_item.child(0).data().toPyObject() 
     252            plot_data = plot_item.child(0).data() #.toPyObject() 
    252253            if plot_data.id is not None and plot_data.id == py_update_data.id: 
    253254                # replace data section in item 
     
    270271    Adds QVariant 'update_data' to that row. 
    271272    """ 
    272     assert isinstance(update_data, QtCore.QVariant) 
    273     py_update_data = update_data.toPyObject() 
     273    #assert isinstance(update_data, QtCore.QVariant) 
     274    #py_update_data = update_data.toPyObject() 
     275    py_update_data = update_data 
    274276 
    275277    checkbox_item = QtGui.QStandardItem() 
     
    309311    object_item = QtGui.QStandardItem() 
    310312    object_item.setText(name) 
    311     object_item.setData(QtCore.QVariant(update_data)) 
     313    #object_item.setData(QtCore.QVariant(update_data)) 
     314    object_item.setData(update_data) 
    312315 
    313316    # Append the new row to the main item 
     
    319322    """ 
    320323    assert isinstance(model_item, QtGui.QStandardItemModel) 
    321     assert isinstance(filename, basestring) 
     324    assert isinstance(filename, str) 
    322325 
    323326    # Iterate over model looking for named items 
    324     item = list(filter(lambda i: str(i.text()) == filename, 
    325                   [model_item.item(index) for index in range(model_item.rowCount())])) 
     327    item = list([i for i in [model_item.item(index) for index in range(model_item.rowCount())] if str(i.text()) == filename]) 
    326328    return item[0] if len(item)>0 else None 
    327329 
     
    331333    """ 
    332334    assert isinstance(model_item, QtGui.QStandardItemModel) 
    333     assert isinstance(filename, basestring) 
     335    assert isinstance(filename, str) 
    334336 
    335337    plot_data = [] 
     
    339341        if str(item.text()) == filename: 
    340342            # TODO: assure item type is correct (either data1/2D or Plotter) 
    341             plot_data.append(item.child(0).data().toPyObject()) 
     343            plot_data.append(item.child(0).data()) #.toPyObject()) 
    342344            # Going 1 level deeper only 
    343345            for index_2 in range(item.rowCount()): 
     
    345347                if item_2 and item_2.isCheckable(): 
    346348                    # TODO: assure item type is correct (either data1/2D or Plotter) 
    347                     plot_data.append(item_2.child(0).data().toPyObject()) 
     349                    plot_data.append(item_2.child(0).data()) #.toPyObject()) 
    348350 
    349351    return plot_data 
     
    361363        if item.isCheckable() and item.checkState() == QtCore.Qt.Checked: 
    362364            # TODO: assure item type is correct (either data1/2D or Plotter) 
    363             plot_data.append((item, item.child(0).data().toPyObject())) 
     365            plot_data.append((item, item.child(0).data())) #.toPyObject())) 
    364366        # Going 1 level deeper only 
    365367        for index_2 in range(item.rowCount()): 
     
    367369            if item_2 and item_2.isCheckable() and item_2.checkState() == QtCore.Qt.Checked: 
    368370                # TODO: assure item type is correct (either data1/2D or Plotter) 
    369                 plot_data.append((item_2, item_2.child(0).data().toPyObject())) 
     371                plot_data.append((item_2, item_2.child(0).data())) #.toPyObject())) 
    370372 
    371373    return plot_data 
     
    419421    Check the URL first, though. 
    420422    """ 
    421     parsed_url = urlparse.urlparse(url) 
     423    parsed_url = urllib.parse.urlparse(url) 
    422424    if parsed_url.scheme: 
    423425        webbrowser.open(url) 
    424426    else: 
    425427        msg = "Attempt at opening an invalid URL" 
    426         raise AttributeError, msg 
     428        raise AttributeError(msg) 
    427429 
    428430def retrieveData1d(data): 
     
    433435    if not isinstance(data, Data1D): 
    434436        msg = "Incorrect type passed to retrieveData1d" 
    435         raise AttributeError, msg 
     437        raise AttributeError(msg) 
    436438    try: 
    437439        xmin = min(data.x) 
     
    441443                    data.filename 
    442444        #logging.error(msg) 
    443         raise ValueError, msg 
     445        raise ValueError(msg) 
    444446 
    445447    text = data.__str__() 
     
    485487    if not isinstance(data, Data2D): 
    486488        msg = "Incorrect type passed to retrieveData2d" 
    487         raise AttributeError, msg 
     489        raise AttributeError(msg) 
    488490 
    489491    text = data.__str__() 
     
    499501    dy_val = 0.0 
    500502    len_data = len(data.qx_data) 
    501     for index in xrange(0, len_data): 
     503    for index in range(0, len_data): 
    502504        x_val = data.qx_data[index] 
    503505        y_val = data.qy_data[index] 
     
    756758    The assumption - data stored in SasView standard, in child 0 
    757759    """ 
    758     return item.child(0).data().toPyObject() 
     760    return item.child(0).data() #.toPyObject() 
    759761 
    760762def formatNumber(value, high=False): 
  • src/sas/qtgui/Utilities/LocalConfig.py

    • Property mode changed from 100644 to 100755
    rdc5ef15 rb3e8629  
    139139    """ 
    140140    if __EVT_DEBUG__: 
    141         print "%g:  %s" % (time.clock(), message) 
     141        print("%g:  %s" % (time.clock(), message)) 
    142142 
    143143        if __EVT_DEBUG_2_FILE__: 
  • src/sas/qtgui/Utilities/ObjectLibrary.py

    r61a92d4 rb3e8629  
    99 
    1010def deleteObjectByRef(obj): 
    11     for name, object in this._objects.iteritems(): 
     11    for name, object in this._objects.items(): 
    1212        if object == obj: 
    1313            del this._objects[name] 
     
    2222 
    2323def listObjects(): 
    24     return this._objects.keys() 
     24    return list(this._objects.keys()) 
    2525 
    2626 
  • src/sas/qtgui/Utilities/SasviewLogger.py

    • Property mode changed from 100644 to 100755
    r83eb5208 rb3e8629  
    1919    def write(self, msg): 
    2020        if(not self.signalsBlocked()): 
    21             self.messageWritten.emit(unicode(msg)) 
     21            self.messageWritten.emit(str(msg)) 
    2222 
    2323    @staticmethod 
  • src/sas/qtgui/convertUI.py

    rcd2cc745 rb3e8629  
    88 
    99def pyuic(in_file, out_file): 
    10     """ Run the pyuic4 script""" 
     10    """ Run the pyuic5 script""" 
    1111    execute = 'pyuic4 -o %s %s' % (out_file, in_file) 
    1212    os.system(execute) 
  • src/sas/sascalc/fit/expression.py

    r574adc7 rb3e8629  
    210210 
    211211    #print("Function: "+functiondef) 
    212     exec functiondef in globals,locals 
     212    exec (functiondef in globals,locals) 
    213213    retfn = locals['eval_expressions'] 
    214214 
Note: See TracChangeset for help on using the changeset viewer.