Changeset b3e8629 in sasview for src/sas/qtgui/Calculators


Ignore:
Timestamp:
Nov 9, 2017 6:41:54 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
cee5c78
Parents:
749b715
git-author:
Piotr Rozyczko <rozyczko@…> (10/26/17 01:13:05)
git-committer:
Piotr Rozyczko <rozyczko@…> (11/09/17 06:41:54)
Message:

Initial changes to make SasView? run with python3

Location:
src/sas/qtgui/Calculators
Files:
8 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) 
Note: See TracChangeset for help on using the changeset viewer.