Changeset 1bc27f1 in sasview
- Timestamp:
- May 11, 2017 4:53:22 AM (8 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:
- d60da0c
- Parents:
- 672b8ab
- Location:
- src/sas/qtgui
- Files:
-
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/GUITests.py
r672b8ab r1bc27f1 50 50 suites = ( 51 51 # Plotting 52 #unittest.makeSuite(PlotHelperTest.PlotHelperTest, 'test'),53 #unittest.makeSuite(PlotterTest.PlotterTest, 'test'),54 #unittest.makeSuite(WindowTitleTest.WindowTitleTest, 'test'),55 #unittest.makeSuite(PlotterBaseTest.PlotterBaseTest, 'test'),56 #unittest.makeSuite(Plotter2DTest.Plotter2DTest, 'test'),57 #unittest.makeSuite(AddTextTest.AddTextTest, 'test'),58 #unittest.makeSuite(ScalePropertiesTest.ScalePropertiesTest, 'test'),59 #unittest.makeSuite(SetGraphRangeTest.SetGraphRangeTest, 'test'),60 #unittest.makeSuite(LinearFitTest.LinearFitTest, 'test'),61 #unittest.makeSuite(PlotPropertiesTest.PlotPropertiesTest, 'test'),62 #unittest.makeSuite(PlotUtilitiesTest.PlotUtilitiesTest, 'test'),63 #unittest.makeSuite(ColorMapTest.ColorMapTest, 'test'),64 #unittest.makeSuite(BoxSumTest.BoxSumTest, 'test'),65 #unittest.makeSuite(SlicerModelTest.SlicerModelTest, 'test'),66 #unittest.makeSuite(SlicerParametersTest.SlicerParametersTest, 'test'),52 unittest.makeSuite(PlotHelperTest.PlotHelperTest, 'test'), 53 unittest.makeSuite(PlotterTest.PlotterTest, 'test'), 54 unittest.makeSuite(WindowTitleTest.WindowTitleTest, 'test'), 55 unittest.makeSuite(PlotterBaseTest.PlotterBaseTest, 'test'), 56 unittest.makeSuite(Plotter2DTest.Plotter2DTest, 'test'), 57 unittest.makeSuite(AddTextTest.AddTextTest, 'test'), 58 unittest.makeSuite(ScalePropertiesTest.ScalePropertiesTest, 'test'), 59 unittest.makeSuite(SetGraphRangeTest.SetGraphRangeTest, 'test'), 60 unittest.makeSuite(LinearFitTest.LinearFitTest, 'test'), 61 unittest.makeSuite(PlotPropertiesTest.PlotPropertiesTest, 'test'), 62 unittest.makeSuite(PlotUtilitiesTest.PlotUtilitiesTest, 'test'), 63 unittest.makeSuite(ColorMapTest.ColorMapTest, 'test'), 64 unittest.makeSuite(BoxSumTest.BoxSumTest, 'test'), 65 unittest.makeSuite(SlicerModelTest.SlicerModelTest, 'test'), 66 unittest.makeSuite(SlicerParametersTest.SlicerParametersTest, 'test'), 67 67 68 # #Main window69 #unittest.makeSuite(AboutBoxTest.AboutBoxTest, 'test'),70 #unittest.makeSuite(DataExplorerTest.DataExplorerTest, 'test'),71 #unittest.makeSuite(WelcomePanelTest.WelcomePanelTest, 'test'),72 #unittest.makeSuite(DroppableDataLoadWidgetTest.DroppableDataLoadWidgetTest, 'test'),73 #unittest.makeSuite(GuiManagerTest.GuiManagerTest, 'test'),74 #unittest.makeSuite(GuiUtilsTest.GuiUtilsTest, 'test'),75 #unittest.makeSuite(MainWindowTest.MainWindowTest, 'test'),68 # Main window 69 unittest.makeSuite(AboutBoxTest.AboutBoxTest, 'test'), 70 unittest.makeSuite(DataExplorerTest.DataExplorerTest, 'test'), 71 unittest.makeSuite(WelcomePanelTest.WelcomePanelTest, 'test'), 72 unittest.makeSuite(DroppableDataLoadWidgetTest.DroppableDataLoadWidgetTest, 'test'), 73 unittest.makeSuite(GuiManagerTest.GuiManagerTest, 'test'), 74 unittest.makeSuite(GuiUtilsTest.GuiUtilsTest, 'test'), 75 unittest.makeSuite(MainWindowTest.MainWindowTest, 'test'), 76 76 77 # #Utilities78 #unittest.makeSuite(TestUtilsTest.TestUtilsTest, 'test'),79 #unittest.makeSuite(SasviewLoggerTest.SasviewLoggerTest, 'test'),77 # Utilities 78 unittest.makeSuite(TestUtilsTest.TestUtilsTest, 'test'), 79 unittest.makeSuite(SasviewLoggerTest.SasviewLoggerTest, 'test'), 80 80 81 # #Calculators82 #unittest.makeSuite(KiessigCalculatorTest.KiessigCalculatorTest, 'test'),83 #unittest.makeSuite(DensityCalculatorTest.DensityCalculatorTest, 'test'),84 #unittest.makeSuite(GenericScatteringCalculatorTest.GenericScatteringCalculatorTest, 'test'),81 # Calculators 82 unittest.makeSuite(KiessigCalculatorTest.KiessigCalculatorTest, 'test'), 83 unittest.makeSuite(DensityCalculatorTest.DensityCalculatorTest, 'test'), 84 unittest.makeSuite(GenericScatteringCalculatorTest.GenericScatteringCalculatorTest, 'test'), 85 85 86 # #Perspectives87 #unittest.makeSuite(FittingPerspectiveTest.FittingPerspectiveTest, 'test'),86 # Perspectives 87 unittest.makeSuite(FittingPerspectiveTest.FittingPerspectiveTest, 'test'), 88 88 unittest.makeSuite(FittingWidgetTest.FittingWidgetTest, 'test'), 89 #unittest.makeSuite(FittingLogicTest.FittingLogicTest, 'test'),90 #unittest.makeSuite(FittingUtilitiesTest.FittingUtilitiesTest, 'test'),89 unittest.makeSuite(FittingLogicTest.FittingLogicTest, 'test'), 90 unittest.makeSuite(FittingUtilitiesTest.FittingUtilitiesTest, 'test'), 91 91 unittest.makeSuite(FitPageTest.FitPageTest, 'test'), 92 92 ) -
src/sas/qtgui/Perspectives/Fitting/FitPage.py
r672b8ab r1bc27f1 1 """ 2 Container class for fitting widget state storage 3 """ 1 4 class FitPage(object): 2 5 """ -
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
r2add354 r1bc27f1 1 import sys2 1 import numpy 3 2 … … 5 4 from PyQt4 import QtGui 6 5 7 import sas.qtgui.Utilities.GuiUtils as GuiUtils8 6 import sas.qtgui.Utilities.ObjectLibrary as ObjectLibrary 9 7 10 from FittingWidget import FittingWidget8 from sas.qtgui.Perspectives.Fitting.FittingWidget import FittingWidget 11 9 #from FitPage import FitPage 12 10 … … 31 29 32 30 # The current optimizer 33 self.optimizer = ' DREAM'31 self.optimizer = 'Levenberg-Marquardt' 34 32 35 33 # The tabs need to be closeable … … 77 75 Add a new tab for passed data 78 76 """ 79 tab = FittingWidget(parent=self.parent, data=data, id=self.maxIndex+1)77 tab = FittingWidget(parent=self.parent, data=data, tab_id=self.maxIndex+1) 80 78 # Add this tab to the object library so it can be retrieved by scripting/jupyter 81 79 ObjectLibrary.addObject(self.tabName(), tab) -
src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
r2add354 r1bc27f1 1 from copy import deepcopy 2 1 3 from PyQt4 import QtGui 2 4 from PyQt4 import QtCore 3 5 4 6 import numpy 5 from copy import deepcopy6 7 7 8 from sas.sasgui.guiframe.dataFitting import Data1D … … 57 58 item1.setCheckable(True) 58 59 item1.setEditable(False) 59 item_err = QtGui.QStandardItem()60 # item_err = QtGui.QStandardItem() 60 61 # check for polydisp params 61 62 if param.polydisperse: … … 199 200 #flag = self.get_weight_flag() 200 201 #weight = get_weight(data=self.data, is2d=self._is_2D(), flag=flag) 201 202 if reference_data ==None:203 return chisqr202 chisqr = None 203 if reference_data is None: 204 return chisqr 204 205 205 206 # temporary default values for index and weight … … 209 210 # Get data: data I, theory I, and data dI in order 210 211 if isinstance(reference_data, Data2D): 211 if index ==None:212 if index is None: 212 213 index = numpy.ones(len(current_data.data), dtype=bool) 213 if weight !=None:214 if weight is not None: 214 215 current_data.err_data = weight 215 216 # get rid of zero error points … … 221 222 else: 222 223 # 1 d theory from model_thread is only in the range of index 223 if index ==None:224 if index is None: 224 225 index = numpy.ones(len(current_data.y), dtype=bool) 225 if weight !=None:226 if weight is not None: 226 227 current_data.dy = weight 227 if current_data.dy ==None or current_data.dy == []:228 if current_data.dy is None or current_data.dy == []: 228 229 dy = numpy.ones(len(current_data.y)) 229 230 else: … … 288 289 residuals.dxw = None 289 290 residuals.ytransform = 'y' 290 # For latter scale changes 291 # For latter scale changes 291 292 residuals.xaxis('\\rm{Q} ', 'A^{-1}') 292 293 residuals.yaxis('\\rm{Residuals} ', 'normalized') … … 299 300 """ 300 301 # temporary default values for index and weight 301 index = None302 # index = None 302 303 weight = None 303 304 … … 351 352 group_id = reference_data.group_id 352 353 residuals.group_id = "res" + str(group_id) 353 354 354 355 # Symbol 355 356 residuals.symbol = 0 -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r672b8ab r1bc27f1 1 import sys2 1 import json 3 2 import os 4 import numpy as np5 3 from collections import defaultdict 6 4 from itertools import izip … … 9 7 import traceback 10 8 from twisted.internet import threads 9 import numpy as np 11 10 12 11 from PyQt4 import QtGui … … 28 27 from sas.sasgui.perspectives.fitting.utils import get_weight 29 28 30 from UI.FittingWidgetUI import Ui_FittingWidgetUI29 from sas.qtgui.Perspectives.Fitting.UI.FittingWidgetUI import Ui_FittingWidgetUI 31 30 from sas.qtgui.Perspectives.Fitting.FittingLogic import FittingLogic 32 31 from sas.qtgui.Perspectives.Fitting import FittingUtilities 33 from SmearingWidget import SmearingWidget34 from OptionsWidget import OptionsWidget35 from FitPage import FitPage32 from sas.qtgui.Perspectives.Fitting.SmearingWidget import SmearingWidget 33 from sas.qtgui.Perspectives.Fitting.OptionsWidget import OptionsWidget 34 from sas.qtgui.Perspectives.Fitting.FitPage import FitPage 36 35 37 36 TAB_MAGNETISM = 4 … … 45 44 Main widget for selecting form and structure factor models 46 45 """ 47 def __init__(self, parent=None, data=None, id=1):46 def __init__(self, parent=None, data=None, tab_id=1): 48 47 49 48 super(FittingWidget, self).__init__() … … 81 80 82 81 # Which tab is this widget displayed in? 83 self.tab_id = id82 self.tab_id = tab_id 84 83 85 84 # Which shell is being currently displayed? … … 98 97 layout = QtGui.QGridLayout() 99 98 self.options_widget = OptionsWidget(self, self.logic) 100 layout.addWidget(self.options_widget) 99 layout.addWidget(self.options_widget) 101 100 self.tabOptions.setLayout(layout) 102 101 … … 104 103 layout = QtGui.QGridLayout() 105 104 self.smearing_widget = SmearingWidget(self) 106 layout.addWidget(self.smearing_widget) 105 layout.addWidget(self.smearing_widget) 107 106 self.tabResolution.setLayout(layout) 108 107 109 108 # Define bold font for use in various controls 110 self.boldFont =QtGui.QFont()109 self.boldFont = QtGui.QFont() 111 110 self.boldFont.setBold(True) 112 111 … … 315 314 """ 316 315 msg = 'Model description:\n' 317 info = "Info"318 316 if self.kernel_module is not None: 319 317 if str(self.kernel_module.description).rstrip().lstrip() == '': … … 358 356 self.createDefaultDataset() 359 357 360 state = self.currentState() 358 # TODO: update state stack 359 #state = self.currentState() 361 360 362 361 def onSelectStructureFactor(self): … … 403 402 # Retrieve the list of models 404 403 model_list = self.master_category_dict[category] 405 models = []406 404 # Populate the models combobox 407 405 self.cbModel.addItems(sorted([model for (model, _) in model_list])) … … 538 536 if res.fitness is None or \ 539 537 not np.isfinite(res.fitness) or \ 540 np.any(res.pvec ==None) or \538 np.any(res.pvec is None) or \ 541 539 not np.all(np.isfinite(res.pvec)): 542 540 msg = "Fitting did not converge!!!" … … 638 636 # Regardless of previous state, this should now be `plot show` functionality only 639 637 self.cmdPlot.setText("Show Plot") 638 if not self.data_is_loaded: 639 self.recalculatePlotData() 640 640 self.showPlot() 641 641 … … 690 690 elif self.log_points: 691 691 qmin = -10.0 if self.q_range_min < 1.e-10 else np.log10(self.q_range_min) 692 qmax = 692 qmax = 10.0 if self.q_range_max > 1.e10 else np.log10(self.q_range_max) 693 693 interval = np.logspace(start=qmin, stop=qmax, num=self.npts, endpoint=True, base=10.0) 694 694 else: 695 695 interval = np.linspace(start=self.q_range_min, stop=self.q_range_max, 696 num=self.npts, endpoint=True)696 num=self.npts, endpoint=True) 697 697 self.logic.createDefault1dData(interval, self.tab_id) 698 698 … … 754 754 """ 755 755 Adds weighting contribution to fitting data 756 #"""756 """ 757 757 # Send original data for weighting 758 758 weight = get_weight(data=data, is2d=self.is2D, flag=self.weighting) … … 856 856 self.kernel_module.params[parameter_name] = value 857 857 858 # TODO: update min/max based on property_name 858 859 # min/max to be changed in self.kernel_module.details[parameter_name] = ['Ang', 0.0, inf] 859 860 # magnetic params in self.kernel_module.details['M0:parameter_name'] = value … … 882 883 self._model_model.blockSignals(True) 883 884 # Convert to proper indices and set requested enablement 884 items= [self._model_model.item(row, 0).setCheckState(status) for row in rows]885 _ = [self._model_model.item(row, 0).setCheckState(status) for row in rows] 885 886 self._model_model.blockSignals(False) 886 887 … … 966 967 # Awful API to a backend method. 967 968 method = self.methodCalculateForData()(data=self.data, 968 model=self.kernel_module,969 page_id=0,970 qmin=self.q_range_min,971 qmax=self.q_range_max,972 smearer=None,973 state=None,974 weight=None,975 fid=None,976 toggle_mode_on=False,977 completefn=None,978 update_chisqr=True,979 exception_handler=self.calcException,980 source=None)969 model=self.kernel_module, 970 page_id=0, 971 qmin=self.q_range_min, 972 qmax=self.q_range_max, 973 smearer=None, 974 state=None, 975 weight=None, 976 fid=None, 977 toggle_mode_on=False, 978 completefn=None, 979 update_chisqr=True, 980 exception_handler=self.calcException, 981 source=None) 981 982 982 983 calc_thread = threads.deferToThread(method.compute) -
src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py
r61a92d4 r1bc27f1 6 6 from PyQt4 import QtCore 7 7 8 from sas.sasgui.guiframe.dataFitting import Data1D9 8 from sas.sasgui.guiframe.dataFitting import Data2D 10 9 11 10 # Local UI 12 from UI.OptionsWidgetUI import Ui_tabOptions11 from sas.qtgui.Perspectives.Fitting.UI.OptionsWidgetUI import Ui_tabOptions 13 12 14 13 QMIN_DEFAULT = 0.0005 … … 50 49 # Logic component 51 50 self.logic = logic 51 self.parent = parent 52 52 53 53 # Weight radio box group … … 105 105 self.mapper.setOrientation(QtCore.Qt.Vertical) 106 106 107 self.mapper.addMapping(self.txtMinRange, 108 self.mapper.addMapping(self.txtMaxRange, 109 self.mapper.addMapping(self.txtNpts, 110 self.mapper.addMapping(self.chkLogData, 107 self.mapper.addMapping(self.txtMinRange, MODEL.index('MIN_RANGE')) 108 self.mapper.addMapping(self.txtMaxRange, MODEL.index('MAX_RANGE')) 109 self.mapper.addMapping(self.txtNpts, MODEL.index('NPTS')) 110 self.mapper.addMapping(self.chkLogData, MODEL.index('LOG_SPACED')) 111 111 self.mapper.toFirst() 112 112 … … 137 137 def onModelChange(self, top, bottom): 138 138 """ 139 Respond to model change by updating 139 Respond to model change by updating the plot 140 140 """ 141 #print "MODEL CHANGED for property: %s. The value is now: %s" % \ 142 # (MODEL[top.row()], str(self.model.item(top.row()).text())) 143 141 # "bottom" is unused 144 142 # update if there's something to update 145 143 if str(self.model.item(top.row()).text()): … … 190 188 q_range_min = float(self.model.item(MODEL.index('MIN_RANGE')).text()) 191 189 q_range_max = float(self.model.item(MODEL.index('MAX_RANGE')).text()) 192 npts 193 log_points 190 npts = int(self.model.item(MODEL.index('NPTS')).text()) 191 log_points = str(self.model.item(MODEL.index('LOG_SPACED')).text()) == 'true' 194 192 195 193 return (q_range_min, q_range_max, npts, log_points, self.weighting) -
src/sas/qtgui/Perspectives/Fitting/SmearingWidget.py
r672b8ab r1bc27f1 9 9 10 10 # Local UI 11 from UI.SmearingWidgetUI import Ui_SmearingWidgetUI11 from sas.qtgui.Perspectives.Fitting.UI.SmearingWidgetUI import Ui_SmearingWidgetUI 12 12 13 13 class DataWidgetMapper(QtGui.QDataWidgetMapper): … … 48 48 self.mapper = None 49 49 50 self.parent = parent 50 51 # Let only floats in the line edits 51 52 self.txtSmearDown.setValidator(QtGui.QDoubleValidator()) -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingPerspectiveTest.py
r83eb5208 r1bc27f1 40 40 self.assertIsInstance(self.widget, QtGui.QWidget) 41 41 self.assertIn("Fit panel", self.widget.windowTitle()) 42 self.assertEqual(self.widget.optimizer, " DREAM")42 self.assertEqual(self.widget.optimizer, "Levenberg-Marquardt") 43 43 self.assertEqual(len(self.widget.tabs), 1) 44 44 self.assertEqual(self.widget.maxIndex, 1) -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
r672b8ab r1bc27f1 74 74 item = QtGui.QStandardItem("test") 75 75 76 widget_with_data = FittingWidget(dummy_manager(), data=item, id=3)76 widget_with_data = FittingWidget(dummy_manager(), data=item, tab_id=3) 77 77 78 78 self.assertEqual(widget_with_data.data, data)
Note: See TracChangeset
for help on using the changeset viewer.