Changeset b3e8629 in sasview for src/sas/qtgui/Calculators
- Timestamp:
- Nov 9, 2017 8:41:54 AM (7 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 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)
- 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 13 13 import sas.qtgui.Utilities.GuiUtils as GuiUtils 14 14 15 from UI.DataOperationUtilityUI import Ui_DataOperationUtility15 from .UI.DataOperationUtilityUI import Ui_DataOperationUtility 16 16 17 17 BG_WHITE = "background-color: rgb(255, 255, 255);" … … 76 76 self.filenames = filenames 77 77 78 if filenames.keys():78 if list(filenames.keys()): 79 79 # clear contents of comboboxes 80 80 self.cbData1.clear() … … 85 85 list_datafiles = [] 86 86 87 for key_id in filenames.keys():87 for key_id in list(filenames.keys()): 88 88 if filenames[key_id].get_data().title: 89 89 # filenames with titles … … 139 139 data1 = self.data1 140 140 data2 = self.data2 141 exec "output = data1 %s data2" % operator141 exec("output = data1 %s data2" % operator) 142 142 except: 143 143 raise … … 300 300 self.cbData1.setStyleSheet(QtCore.QString(BG_RED)) 301 301 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__) 303 303 logging.warning('Cannot compute data of different dimensions') 304 304 return False … … 354 354 def _findId(self, name): 355 355 """ 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()): 359 359 # data with title 360 360 if self.filenames[key_id].get_data().title: -
src/sas/qtgui/Calculators/DensityPanel.py
- Property mode changed from 100644 to 100755
rb0c5e8c rb3e8629 14 14 15 15 def enum(*sequential, **named): 16 enums = dict( zip(sequential, range(len(sequential))), **named)16 enums = dict(list(zip(sequential, list(range(len(sequential))))), **named) 17 17 return type('Enum', (), enums) 18 18 … … 95 95 96 96 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): 98 98 if index == MODEL.MOLECULAR_FORMULA: 99 99 molarMass = toMolarMass(self.model.item(MODEL.MOLECULAR_FORMULA).text()) -
src/sas/qtgui/Calculators/GenericScatteringCalculator.py
- Property mode changed from 100644 to 100755
rfef38e8 rb3e8629 22 22 23 23 # Local UI 24 from UI.GenericScatteringCalculator import Ui_GenericScatteringCalculator24 from .UI.GenericScatteringCalculator import Ui_GenericScatteringCalculator 25 25 26 26 _Q1D_MIN = 0.001 … … 119 119 TODO Temporary solution to display information about option 'Ellipsoid' 120 120 """ 121 print "The option Ellipsoid has not been implemented yet."121 print("The option Ellipsoid has not been implemented yet.") 122 122 self.communicator.statusBarUpdateSignal.emit( 123 123 "The option Ellipsoid has not been implemented yet.") … … 165 165 self.reader.queue() 166 166 except (RuntimeError, IOError): 167 log_msg = "Generic SAS Calculator: %s" % sys.exc_ value167 log_msg = "Generic SAS Calculator: %s" % sys.exc_info()[1] 168 168 logging.info(log_msg) 169 169 raise … … 556 556 d.addCallback(self.plot_1_2d) 557 557 except: 558 log_msg = "{}. stop".format(sys.exc_ value)558 log_msg = "{}. stop".format(sys.exc_info()[1]) 559 559 logging.info(log_msg) 560 560 return … … 644 644 self.graph_num += 1 645 645 # TODO 646 print 'TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED'646 print('TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED') 647 647 return plot1D 648 648 else: … … 662 662 self.graph_num += 1 663 663 # TODO 664 print 'TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED'664 print('TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED') 665 665 return plot2D 666 666 … … 744 744 # II. Plot selective points in color 745 745 other_color = numpy.ones(len(pix_symbol), dtype='bool') 746 for key in color_dic.keys():746 for key in list(color_dic.keys()): 747 747 chosen_color = pix_symbol == key 748 748 if numpy.any(chosen_color): … … 758 758 # Get atom names not in the list 759 759 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())] 761 761 a_name = a_names[0] 762 762 for name in a_names: -
src/sas/qtgui/Calculators/KiessigPanel.py
- Property mode changed from 100644 to 100755
rb0c5e8c rb3e8629 3 3 4 4 from sas.qtgui.UI import main_resources_rc 5 from UI.KiessigPanel import Ui_KiessigPanel5 from .UI.KiessigPanel import Ui_KiessigPanel 6 6 import sas.qtgui.Utilities.GuiUtils as GuiUtils 7 7 -
src/sas/qtgui/Calculators/ResolutionCalculatorPanel.py
- Property mode changed from 100644 to 100755
r170e95d rb3e8629 20 20 import re 21 21 22 from UI.ResolutionCalculatorPanelUI import Ui_ResolutionCalculatorPanel22 from .UI.ResolutionCalculatorPanelUI import Ui_ResolutionCalculatorPanel 23 23 24 24 _SOURCE_MASS = {'Alpha': 6.64465620E-24, … … 318 318 self, "Choose a spectral distribution file", "", 319 319 "All files (*.*)", 320 None,QtGui.QFileDialog.DontUseNativeDialog)320 QtGui.QFileDialog.DontUseNativeDialog) 321 321 322 322 if datafile is None or str(datafile) == '': … … 328 328 try: 329 329 basename = os.path.basename(datafile) 330 if basename not in self.spectrum_dic.keys():330 if basename not in list(self.spectrum_dic.keys()): 331 331 self.cbCustomSpectrum.addItem(basename) 332 332 … … 604 604 msg = "The numbers must be one or two (separated by ',')" 605 605 logging.info(msg) 606 raise RuntimeError , msg606 raise RuntimeError(msg) 607 607 608 608 return new_numbers_list … … 618 618 new_list = [float(t) for t in string_split] 619 619 except: 620 logging.error(sys.exc_ value)620 logging.error(sys.exc_info()[1]) 621 621 return new_list 622 622 … … 658 658 return out 659 659 except: 660 logging.error(sys.exc_ value)660 logging.error(sys.exc_info()[1]) 661 661 662 662 def _validate_q_input(self, qx, qy): -
src/sas/qtgui/Calculators/SldPanel.py
- Property mode changed from 100644 to 100755
rb0c5e8c rb3e8629 15 15 16 16 def enum(*sequential, **named): 17 enums = dict( zip(sequential, range(len(sequential))), **named)17 enums = dict(list(zip(sequential, list(range(len(sequential))))), **named) 18 18 return type('Enum', (), enums) 19 19 … … 60 60 if len(formula.atoms) != 1: 61 61 raise NotImplementedError() 62 energy = xray_energy( formula.atoms.keys()[0].K_alpha)62 energy = xray_energy(list(formula.atoms.keys())[0].K_alpha) 63 63 return xray_sld_from_atoms( 64 64 sld_formula.atoms, … … 142 142 self.model.setItem(MODEL.WAVELENGTH , QtGui.QStandardItem()) 143 143 144 for key in self._getOutputs().keys():144 for key in list(self._getOutputs().keys()): 145 145 self.model.setItem(key, QtGui.QStandardItem()) 146 146 … … 161 161 self.mapper.addMapping(self.ui.editWavelength , MODEL.WAVELENGTH) 162 162 163 for key, edit in self._getOutputs().ite ritems():163 for key, edit in self._getOutputs().items(): 164 164 self.mapper.addMapping(edit, key) 165 165 … … 168 168 def dataChanged(self, top, bottom): 169 169 update = False 170 for index in xrange(top.row(), bottom.row() + 1):170 for index in range(top.row(), bottom.row() + 1): 171 171 if (index == MODEL.MOLECULAR_FORMULA) or (index == MODEL.MASS_DENSITY) or (index == MODEL.WAVELENGTH): 172 172 update = True … … 202 202 pass 203 203 204 for key in self._getOutputs().keys():204 for key in list(self._getOutputs().keys()): 205 205 self.model.item(key).setText("") 206 206 -
src/sas/qtgui/Calculators/SlitSizeCalculator.py
- Property mode changed from 100644 to 100755
rf4a1433 rb3e8629 11 11 import sas.qtgui.Utilities.GuiUtils as GuiUtils 12 12 13 from UI.SlitSizeCalculator import Ui_SlitSizeCalculator13 from .UI.SlitSizeCalculator import Ui_SlitSizeCalculator 14 14 from sas.sascalc.dataloader.loader import Loader 15 15 from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator … … 76 76 # But only with Qt built-in dialog (non-platform native) 77 77 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)", 79 79 QtGui.QFileDialog.DontUseNativeDialog) 80 80 … … 107 107 self.clearResults() 108 108 msg = "ERROR: Data hasn't been loaded correctly" 109 raise RuntimeError , msg109 raise RuntimeError(msg) 110 110 111 111 if data.__class__.__name__ == 'Data2D': 112 112 self.clearResults() 113 113 msg = "Slit Length cannot be computed for 2D Data" 114 raise RuntimeError , msg114 raise RuntimeError(msg) 115 115 116 116 #compute the slit size … … 120 120 if xdata == [] or xdata is None or ydata == [] or ydata is None: 121 121 msg = "The current data is empty please check x and y" 122 raise ValueError , msg122 raise ValueError(msg) 123 123 slit_length_calculator = SlitlengthCalculator() 124 124 slit_length_calculator.set_data(x=xdata, y=ydata) … … 126 126 except: 127 127 self.clearResults() 128 msg = "Slit Size Calculator: %s" % (sys.exc_ value)129 raise RuntimeError , msg128 msg = "Slit Size Calculator: %s" % (sys.exc_info()[1]) 129 raise RuntimeError(msg) 130 130 131 131 slit_length_str = "{:.5f}".format(slit_length) -
src/sas/qtgui/Calculators/UnitTesting/SlitSizeCalculatorTest.py
- Property mode changed from 100644 to 100755
rf4a1433 rb3e8629 84 84 loader = Loader() 85 85 data = loader.load(filename)[0] 86 self.assertRaisesRegex p(RuntimeError,86 self.assertRaisesRegex(RuntimeError, 87 87 "Slit Length cannot be computed for 2D Data", 88 88 self.widget.calculateSlitSize, data) 89 89 90 90 data = None 91 self.assertRaisesRegex p(RuntimeError,91 self.assertRaisesRegex(RuntimeError, 92 92 "ERROR: Data hasn't been loaded correctly", 93 93 self.widget.calculateSlitSize, data)
Note: See TracChangeset
for help on using the changeset viewer.