Changeset 1ba88515 in sasview


Ignore:
Timestamp:
Nov 9, 2017 6:57:44 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:
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.
Message:

Merge branch 'ESS_GUI_Py3_Qt5' of https://github.com/SasView/sasview into ESS_GUI_Py3_Qt5

Location:
src/sas
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • src/sas/_config.py

    r88e1f57 rf7d14a1  
    110110        try: 
    111111            module = load_module_from_path('sas.custom_config', path) 
    112             logger.info("GuiManager loaded %s", path) 
     112            #logger.info("GuiManager loaded %s", path) 
    113113            return module 
    114114        except Exception as exc: 
  • src/sas/qtgui/MainWindow/GuiManager.py

    r412e069e rd6b8a1d  
    184184        Respond to change of the perspective signal 
    185185        """ 
     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 
    186192        # Close the previous perspective 
     193        self.clearPerspectiveMenubarOptions(self._current_perspective) 
    187194        if self._current_perspective: 
    188195            self._current_perspective.setClosable() 
     
    390397        self._workspace.actionCombine_Batch_Fit.triggered.connect(self.actionCombine_Batch_Fit) 
    391398        self._workspace.actionFit_Options.triggered.connect(self.actionFit_Options) 
     399        self._workspace.actionGPU_Options.triggered.connect(self.actionGPU_Options) 
    392400        self._workspace.actionFit_Results.triggered.connect(self.actionFit_Results) 
    393401        self._workspace.actionChain_Fitting.triggered.connect(self.actionChain_Fitting) 
     
    625633        pass 
    626634 
     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 
    627643    def actionFit_Results(self): 
    628644        """ 
     
    646662    def actionFitting(self): 
    647663        """ 
    648         """ 
    649         print("actionFitting TRIGGERED") 
    650         pass 
     664        Change to the Fitting perspective 
     665        """ 
     666        self.perspectiveChanged("Fitting") 
    651667 
    652668    def actionInversion(self): 
    653669        """ 
    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) 
    655674        print("actionInversion TRIGGERED") 
    656         pass 
     675        # to here and uncomment the following line 
     676        # self.perspectiveChanged("Inversion") 
    657677 
    658678    def actionInvariant(self): 
    659679        """ 
    660         """ 
    661         print("actionInvariant TRIGGERED") 
    662         pass 
     680        Change to the Invariant perspective 
     681        """ 
     682        self.perspectiveChanged("Invariant") 
    663683 
    664684    #============ WINDOW ================= 
     
    759779        if hasattr(self, "filesWidget"): 
    760780            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  
    2525     <y>0</y> 
    2626     <width>915</width> 
    27      <height>21</height> 
     27     <height>26</height> 
    2828    </rect> 
    2929   </property> 
     
    103103    <addaction name="separator"/> 
    104104    <addaction name="actionFit_Options"/> 
     105    <addaction name="actionGPU_Options"/> 
    105106    <addaction name="actionFit_Results"/> 
    106107    <addaction name="separator"/> 
     
    499500   </property> 
    500501  </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> 
    501510 </widget> 
    502511 <resources/> 
  • src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py

    r3e8dee3 r53c771e  
    171171 
    172172        # 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"] 
    175174        self.form.readData(filename) 
    176175 
  • src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py

    r0849aec r4992ff2  
    1212from sas.qtgui.Perspectives.Fitting.FittingWidget import FittingWidget 
    1313from sas.qtgui.Perspectives.Fitting.FittingOptions import FittingOptions 
     14from sas.qtgui.Perspectives.Fitting.GPUOptions import GPUOptions 
    1415#from sas.qtgui.Perspectives.Fitting import ModelUtilities 
    1516 
     
    6364        self.fit_options_widget.fit_option_changed.connect(self.onFittingOptionsChange) 
    6465 
    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) 
    6968 
    7069        #self.setWindowTitle('Fit panel - Active Fitting Optimizer: %s' % self.optimizer) 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r3e8dee3 r53c771e  
    1818#from PyQt5 import QtWebEngineWidgets 
    1919 
     20from sasmodels import product 
    2021from sasmodels import generate 
    2122from sasmodels import modelinfo 
     
    151152    def data(self, value): 
    152153        """ 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. 
    153156        if isinstance(value, list): 
    154157            self.is_batch_fitting = True 
     
    164167 
    165168        # Update logics with data items 
     169        # Logics.data contains only a single Data1D/Data2D object 
    166170        self.logic.data = GuiUtils.dataFromItem(value[0]) 
    167171 
     
    169173        self.is2D = True if isinstance(self.logic.data, Data2D) else False 
    170174 
     175        # Let others know we're full of data now 
    171176        self.data_is_loaded = True 
    172177 
     
    348353        self.chk2DView.setVisible(False) 
    349354        self.chkMagnetism.setEnabled(self.is2D) 
     355        self.tabFitting.setTabEnabled(TAB_MAGNETISM, self.is2D) 
    350356        # Combo box or label for file name" 
    351357        if self.is_batch_fitting: 
     
    12821288        structure_module = generate.load_kernel_module(structure_factor) 
    12831289        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) 
    12841293 
    12851294        new_rows = FittingUtilities.addSimpleParametersToModel(structure_parameters, self.is2D) 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py

    r3e8dee3 r53c771e  
    104104        self.assertEqual(delegate.editableParameters(), [1, 2, 3, 4, 5]) 
    105105        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]) 
    106139        self.assertIsInstance(delegate.combo_updated, QtCore.pyqtBoundSignal) 
    107140 
     
    827860        self.assertEqual(self.widget.cbModel.currentText(), 'onion') 
    828861        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)) 
    829921 
    830922    def testCurrentState(self): 
  • src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py

    r412e069e rd6b8a1d  
    220220 
    221221    def editableParameters(self): 
    222         return [self.mag_min, self.mag_max] 
     222        return [self.mag_value, self.mag_min, self.mag_max] 
    223223 
    224224    def addErrorColumn(self): 
  • src/sas/qtgui/Plotting/Plotter.py

    r6280464 rfbfc488  
    5151        self.xLabel = "%s(%s)"%(value._xaxis, value._xunit) 
    5252        self.yLabel = "%s(%s)"%(value._yaxis, value._yunit) 
     53        if value.isSesans: 
     54            self.xscale = 'linear' 
     55            self.yscale = 'linear' 
    5356        self.title(title=value.name) 
    5457 
  • src/sas/qtgui/Plotting/PlotterData.py

    r895e7359 rcee5c78  
    5454        self.yaxis(data1d._yaxis, data1d._yunit) 
    5555        self.title = data1d.title 
     56        self.isSesans = data1d.isSesans 
    5657         
    5758    def __str__(self): 
  • src/sas/qtgui/Plotting/UnitTesting/PlotterTest.py

    r3e8dee3 r53c771e  
    7777        self.assertTrue(FigureCanvas.draw_idle.called) 
    7878        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) 
    79100 
    80101    def testCreateContextMenuQuick(self): 
  • src/sas/sascalc/dataloader/data_info.py

    r9e6aeaf r749b715  
    775775        clone.meta_data = deepcopy(self.meta_data) 
    776776        clone.errors = deepcopy(self.errors) 
     777        clone.isSesans = self.isSesans 
    777778 
    778779        return clone 
Note: See TracChangeset for help on using the changeset viewer.