Changeset 1ba88515 in sasview
- Timestamp:
- Nov 9, 2017 6:57:44 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:
- 1543f0c
- Parents:
- dd150ef (diff), 0e80658 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas
- Files:
-
- 3 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/_config.py
r88e1f57 rf7d14a1 110 110 try: 111 111 module = load_module_from_path('sas.custom_config', path) 112 logger.info("GuiManager loaded %s", path)112 #logger.info("GuiManager loaded %s", path) 113 113 return module 114 114 except Exception as exc: -
src/sas/qtgui/MainWindow/GuiManager.py
r412e069e rd6b8a1d 184 184 Respond to change of the perspective signal 185 185 """ 186 187 # Save users from themselves... 188 if isinstance(self._current_perspective, Perspectives.PERSPECTIVES[str(perspective_name)]): 189 self.setupPerspectiveMenubarOptions(self._current_perspective) 190 return 191 186 192 # Close the previous perspective 193 self.clearPerspectiveMenubarOptions(self._current_perspective) 187 194 if self._current_perspective: 188 195 self._current_perspective.setClosable() … … 390 397 self._workspace.actionCombine_Batch_Fit.triggered.connect(self.actionCombine_Batch_Fit) 391 398 self._workspace.actionFit_Options.triggered.connect(self.actionFit_Options) 399 self._workspace.actionGPU_Options.triggered.connect(self.actionGPU_Options) 392 400 self._workspace.actionFit_Results.triggered.connect(self.actionFit_Results) 393 401 self._workspace.actionChain_Fitting.triggered.connect(self.actionChain_Fitting) … … 625 633 pass 626 634 635 def actionGPU_Options(self): 636 """ 637 Load the OpenCL selection dialog if the fitting perspective is active 638 """ 639 if hasattr(self._current_perspective, "gpu_options_widget"): 640 self._current_perspective.gpu_options_widget.show() 641 pass 642 627 643 def actionFit_Results(self): 628 644 """ … … 646 662 def actionFitting(self): 647 663 """ 648 """649 print("actionFitting TRIGGERED")650 pass664 Change to the Fitting perspective 665 """ 666 self.perspectiveChanged("Fitting") 651 667 652 668 def actionInversion(self): 653 669 """ 654 """ 670 Change to the Inversion perspective 671 """ 672 # For now we'll just update the analysis menu status but when the inversion is implemented delete from here 673 self.checkAnalysisOption(self._workspace.actionInversion) 655 674 print("actionInversion TRIGGERED") 656 pass 675 # to here and uncomment the following line 676 # self.perspectiveChanged("Inversion") 657 677 658 678 def actionInvariant(self): 659 679 """ 660 """661 print("actionInvariant TRIGGERED")662 pass680 Change to the Invariant perspective 681 """ 682 self.perspectiveChanged("Invariant") 663 683 664 684 #============ WINDOW ================= … … 759 779 if hasattr(self, "filesWidget"): 760 780 self.filesWidget.displayData(plot) 781 782 def uncheckAllMenuItems(self, menuObject): 783 """ 784 Uncheck all options in a given menu 785 """ 786 menuObjects = menuObject.actions() 787 788 for menuItem in menuObjects: 789 menuItem.setChecked(False) 790 791 def checkAnalysisOption(self, analysisMenuOption): 792 """ 793 Unchecks all the items in the analysis menu and checks the item passed 794 """ 795 self.uncheckAllMenuItems(self._workspace.menuAnalysis) 796 analysisMenuOption.setChecked(True) 797 798 def clearPerspectiveMenubarOptions(self, perspective): 799 """ 800 When closing a perspective, clears the menu bar 801 """ 802 for menuItem in self._workspace.menuAnalysis.actions(): 803 menuItem.setChecked(False) 804 805 if isinstance(self._current_perspective, Perspectives.PERSPECTIVES["Fitting"]): 806 self._workspace.menubar.removeAction(self._workspace.menuFitting.menuAction()) 807 808 def setupPerspectiveMenubarOptions(self, perspective): 809 """ 810 When setting a perspective, sets up the menu bar 811 """ 812 if isinstance(perspective, Perspectives.PERSPECTIVES["Fitting"]): 813 self.checkAnalysisOption(self._workspace.actionFitting) 814 # Put the fitting menu back in 815 # This is a bit involved but it is needed to preserve the menu ordering 816 self._workspace.menubar.removeAction(self._workspace.menuWindow.menuAction()) 817 self._workspace.menubar.removeAction(self._workspace.menuHelp.menuAction()) 818 self._workspace.menubar.addAction(self._workspace.menuFitting.menuAction()) 819 self._workspace.menubar.addAction(self._workspace.menuWindow.menuAction()) 820 self._workspace.menubar.addAction(self._workspace.menuHelp.menuAction()) 821 elif isinstance(perspective, Perspectives.PERSPECTIVES["Invariant"]): 822 self.checkAnalysisOption(self._workspace.actionInvariant) 823 # elif isinstance(perspective, Perspectives.PERSPECTIVES["Inversion"]): 824 # self.checkAnalysisOption(self._workspace.actionInversion) -
src/sas/qtgui/MainWindow/UI/MainWindowUI.ui
rb00414d r06ce180 25 25 <y>0</y> 26 26 <width>915</width> 27 <height>2 1</height>27 <height>26</height> 28 28 </rect> 29 29 </property> … … 103 103 <addaction name="separator"/> 104 104 <addaction name="actionFit_Options"/> 105 <addaction name="actionGPU_Options"/> 105 106 <addaction name="actionFit_Results"/> 106 107 <addaction name="separator"/> … … 499 500 </property> 500 501 </action> 502 <action name="actionGPU_Options"> 503 <property name="text"> 504 <string>GPU Options</string> 505 </property> 506 <property name="softKeyRole"> 507 <enum>QAction::NoSoftKey</enum> 508 </property> 509 </action> 501 510 </widget> 502 511 <resources/> -
src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py
r3e8dee3 r53c771e 171 171 172 172 # Populate the model 173 #filename = ["cyl_400_20.txt", "P123_D2O_10_percent.dat", "cyl_400_20.txt"] 174 filename = ["cyl_400_20.txt", "cyl_400_20.txt", "P123_D2O_10_percent.dat"] 173 filename = ["cyl_400_20.txt", "cyl_400_20.txt", "cyl_400_20.txt"] 175 174 self.form.readData(filename) 176 175 -
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
r0849aec r4992ff2 12 12 from sas.qtgui.Perspectives.Fitting.FittingWidget import FittingWidget 13 13 from sas.qtgui.Perspectives.Fitting.FittingOptions import FittingOptions 14 from sas.qtgui.Perspectives.Fitting.GPUOptions import GPUOptions 14 15 #from sas.qtgui.Perspectives.Fitting import ModelUtilities 15 16 … … 63 64 self.fit_options_widget.fit_option_changed.connect(self.onFittingOptionsChange) 64 65 65 #self.menu_manager = ModelUtilities.ModelManager() 66 ## TODO: reuse these in FittingWidget properly 67 #self.model_list_box = self.menu_manager.get_model_list() 68 #self.model_dictionary = self.menu_manager.get_model_dictionary() 66 # GPU Options 67 self.gpu_options_widget = GPUOptions(self) 69 68 70 69 #self.setWindowTitle('Fit panel - Active Fitting Optimizer: %s' % self.optimizer) -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r3e8dee3 r53c771e 18 18 #from PyQt5 import QtWebEngineWidgets 19 19 20 from sasmodels import product 20 21 from sasmodels import generate 21 22 from sasmodels import modelinfo … … 151 152 def data(self, value): 152 153 """ data setter """ 154 # Value is either a list of indices for batch fitting or a simple index 155 # for standard fitting. Assure we have a list, regardless. 153 156 if isinstance(value, list): 154 157 self.is_batch_fitting = True … … 164 167 165 168 # Update logics with data items 169 # Logics.data contains only a single Data1D/Data2D object 166 170 self.logic.data = GuiUtils.dataFromItem(value[0]) 167 171 … … 169 173 self.is2D = True if isinstance(self.logic.data, Data2D) else False 170 174 175 # Let others know we're full of data now 171 176 self.data_is_loaded = True 172 177 … … 348 353 self.chk2DView.setVisible(False) 349 354 self.chkMagnetism.setEnabled(self.is2D) 355 self.tabFitting.setTabEnabled(TAB_MAGNETISM, self.is2D) 350 356 # Combo box or label for file name" 351 357 if self.is_batch_fitting: … … 1282 1288 structure_module = generate.load_kernel_module(structure_factor) 1283 1289 structure_parameters = modelinfo.make_parameter_table(getattr(structure_module, 'parameters', [])) 1290 structure_kernel = self.models[structure_factor]() 1291 1292 self.kernel_module._model_info = product.make_product_info(self.kernel_module._model_info, structure_kernel._model_info) 1284 1293 1285 1294 new_rows = FittingUtilities.addSimpleParametersToModel(structure_parameters, self.is2D) -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py
r3e8dee3 r53c771e 104 104 self.assertEqual(delegate.editableParameters(), [1, 2, 3, 4, 5]) 105 105 self.assertEqual(delegate.poly_function, 6) 106 self.assertIsInstance(delegate.combo_updated, QtCore.pyqtBoundSignal) 107 108 def testSelectMagnetism(self): 109 """ 110 Test if models have been loaded properly 111 """ 112 fittingWindow = self.widget 113 114 self.assertIsInstance(fittingWindow.lstMagnetic.itemDelegate(), QtGui.QStyledItemDelegate) 115 #Test loading from json categories 116 fittingWindow.SASModelToQModel("cylinder") 117 mag_index = fittingWindow.lstMagnetic.model().index(0,0) 118 self.assertEqual(str(mag_index.data().toString()), "up:frac_i") 119 mag_index = fittingWindow.lstMagnetic.model().index(1,0) 120 self.assertEqual(str(mag_index.data().toString()), "up:frac_f") 121 mag_index = fittingWindow.lstMagnetic.model().index(2,0) 122 self.assertEqual(str(mag_index.data().toString()), "up:angle") 123 mag_index = fittingWindow.lstMagnetic.model().index(3,0) 124 self.assertEqual(str(mag_index.data().toString()), "M0:sld") 125 mag_index = fittingWindow.lstMagnetic.model().index(4,0) 126 self.assertEqual(str(mag_index.data().toString()), "mtheta:sld") 127 mag_index = fittingWindow.lstMagnetic.model().index(5,0) 128 self.assertEqual(str(mag_index.data().toString()), "mphi:sld") 129 mag_index = fittingWindow.lstMagnetic.model().index(6,0) 130 self.assertEqual(str(mag_index.data().toString()), "M0:sld_solvent") 131 mag_index = fittingWindow.lstMagnetic.model().index(7,0) 132 self.assertEqual(str(mag_index.data().toString()), "mtheta:sld_solvent") 133 mag_index = fittingWindow.lstMagnetic.model().index(8,0) 134 self.assertEqual(str(mag_index.data().toString()), "mphi:sld_solvent") 135 136 # test the delegate a bit 137 delegate = fittingWindow.lstMagnetic.itemDelegate() 138 self.assertEqual(delegate.editableParameters(), [1, 2, 3]) 106 139 self.assertIsInstance(delegate.combo_updated, QtCore.pyqtBoundSignal) 107 140 … … 827 860 self.assertEqual(self.widget.cbModel.currentText(), 'onion') 828 861 self.assertTrue(self.widget.chkPolydispersity.isChecked()) 862 #Check if polidispersity tab is available 863 self.assertTrue(self.widget.tabFitting.isTabEnabled(3)) 864 865 #Check if magnetism box and tab are disabled when 1D data is loaded 866 self.assertFalse(self.widget.chkMagnetism.isEnabled()) 867 self.assertFalse(self.widget.tabFitting.isTabEnabled(4)) 868 869 def testReadFitPage2D(self): 870 """ 871 Read in the fitpage object and restore state 872 """ 873 # Set data 874 875 test_data = Data2D(image=[1.0, 2.0, 3.0], 876 err_image=[0.01, 0.02, 0.03], 877 qx_data=[0.1, 0.2, 0.3], 878 qy_data=[0.1, 0.2, 0.3], 879 xmin=0.1, xmax=0.3, ymin=0.1, ymax=0.3, 880 mask=[True, True, True]) 881 882 # Force same data into logic 883 self.widget.logic.data = test_data 884 self.widget.data_is_loaded = True 885 886 #item = QtGui.QStandardItem() 887 #updateModelItem(item, [test_data], "test") 888 # Force same data into logic 889 #self.widget.logic.data = item 890 #self.widget.data_is_loaded = True 891 892 category_index = self.widget.cbCategory.findText("Cylinder") 893 self.widget.cbCategory.setCurrentIndex(category_index) 894 895 # Test no fitting params 896 self.widget.parameters_to_fit = ['scale'] 897 898 # Invoke the tested method 899 fp = self.widget.currentState() 900 901 # Prepare modified fit page 902 fp.current_model = 'cylinder' 903 fp.is_polydisperse = True 904 fp.is_magnetic = True 905 fp.is2D = True 906 907 # Read in modified state 908 self.widget.readFitPage(fp) 909 910 # Check if the widget got updated accordingly 911 self.assertEqual(self.widget.cbModel.currentText(), 'cylinder') 912 self.assertTrue(self.widget.chkPolydispersity.isChecked()) 913 self.assertTrue(self.widget.chkPolydispersity.isEnabled()) 914 #Check if polidispersity tab is available 915 self.assertTrue(self.widget.tabFitting.isTabEnabled(3)) 916 917 #Check if magnetism box and tab are disabled when 1D data is loaded 918 self.assertTrue(self.widget.chkMagnetism.isChecked()) 919 self.assertTrue(self.widget.chkMagnetism.isEnabled()) 920 self.assertTrue(self.widget.tabFitting.isTabEnabled(4)) 829 921 830 922 def testCurrentState(self): -
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
r412e069e rd6b8a1d 220 220 221 221 def editableParameters(self): 222 return [self.mag_ min, self.mag_max]222 return [self.mag_value, self.mag_min, self.mag_max] 223 223 224 224 def addErrorColumn(self): -
src/sas/qtgui/Plotting/Plotter.py
r6280464 rfbfc488 51 51 self.xLabel = "%s(%s)"%(value._xaxis, value._xunit) 52 52 self.yLabel = "%s(%s)"%(value._yaxis, value._yunit) 53 if value.isSesans: 54 self.xscale = 'linear' 55 self.yscale = 'linear' 53 56 self.title(title=value.name) 54 57 -
src/sas/qtgui/Plotting/PlotterData.py
r895e7359 rcee5c78 54 54 self.yaxis(data1d._yaxis, data1d._yunit) 55 55 self.title = data1d.title 56 self.isSesans = data1d.isSesans 56 57 57 58 def __str__(self): -
src/sas/qtgui/Plotting/UnitTesting/PlotterTest.py
r3e8dee3 r53c771e 77 77 self.assertTrue(FigureCanvas.draw_idle.called) 78 78 self.plotter.figure.clf() 79 80 def testPlotWithSesans(self): 81 """ Ensure that Sesans data is plotted in linear cooredinates""" 82 data = Data1D(x=[1.0, 2.0, 3.0], 83 y=[10.0, 11.0, 12.0], 84 dx=[0.1, 0.2, 0.3], 85 dy=[0.1, 0.2, 0.3]) 86 data.title = "Sesans data" 87 data.name = "Test Sesans" 88 data.isSesans = True 89 data.id = 2 90 91 self.plotter.data = data 92 self.plotter.show() 93 FigureCanvas.draw = MagicMock() 94 95 self.plotter.plot(hide_error=True) 96 97 self.assertEqual(self.plotter.ax.get_xscale(), 'linear') 98 self.assertEqual(self.plotter.ax.get_yscale(), 'linear') 99 self.assertTrue(FigureCanvas.draw.called) 79 100 80 101 def testCreateContextMenuQuick(self): -
src/sas/sascalc/dataloader/data_info.py
r9e6aeaf r749b715 775 775 clone.meta_data = deepcopy(self.meta_data) 776 776 clone.errors = deepcopy(self.errors) 777 clone.isSesans = self.isSesans 777 778 778 779 return clone
Note: See TracChangeset
for help on using the changeset viewer.