Changeset 605d944 in sasview


Ignore:
Timestamp:
Sep 6, 2018 5:11:49 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
c0de493
Parents:
fd7ef36
git-author:
Piotr Rozyczko <rozyczko@…> (09/06/18 05:10:43)
git-committer:
Piotr Rozyczko <rozyczko@…> (09/06/18 05:11:49)
Message:

Fixed unit tests for fitting SASVIEW-1024
Corrected behaviour of the Structure factor combo box on model/category change

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    rfd7ef36 r605d944  
    968968        self.has_poly_error_column = False 
    969969 
    970         self.respondToModelStructure(model=model, structure_factor=None) 
     970        structure = None 
     971        if self.cbStructureFactor.isEnabled(): 
     972            structure = str(self.cbStructureFactor.currentText()) 
     973        self.respondToModelStructure(model=model, structure_factor=structure) 
    971974 
    972975    def onSelectBatchFilename(self, data_index): 
     
    19621965            # Allow the SF combobox visibility for the given sasmodel 
    19631966            self.enableStructureFactorControl(structure_factor) 
     1967            if self.cbStructureFactor.isEnabled(): 
     1968                structure_factor = self.cbStructureFactor.currentText() 
     1969                self.fromStructureFactorToQModel(structure_factor) 
    19641970 
    19651971        # Then, add multishells 
     
    20562062        Setting model parameters into QStandardItemModel based on selected _structure factor_ 
    20572063        """ 
     2064        if structure_factor is None or structure_factor=="None": 
     2065            return 
    20582066        structure_module = generate.load_kernel_module(structure_factor) 
    20592067        structure_parameters = modelinfo.make_parameter_table(getattr(structure_module, 'parameters', [])) 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py

    rb764ae5 r605d944  
    262262        self.widget.cbModel.setCurrentIndex(0) 
    263263 
    264         # Observe factor reset to None 
    265         self.assertEqual(self.widget.cbStructureFactor.currentText(), STRUCTURE_DEFAULT) 
     264        # Observe factor doesn't reset to None 
     265        self.assertEqual(self.widget.cbStructureFactor.currentText(), 'squarewell') 
    266266 
    267267        # Switch category to structure factor 
     
    639639        self.assertEqual(spy.count(), 0) 
    640640 
    641     def notestPlotData(self): 
     641    def testPlotData(self): 
    642642        """ 
    643643        See that data item can produce a chart 
     
    649649        # Set data 
    650650        test_data = Data1D(x=[1,2], y=[1,2]) 
    651  
     651        item = QtGui.QStandardItem() 
     652        updateModelItem(item, test_data, "test") 
    652653        # Force same data into logic 
    653         self.widget.logic.data = test_data 
    654         self.widget.data_is_loaded = True 
     654        self.widget.data = item 
    655655 
    656656        # Change the category index so we have a model available 
     
    674674        self.assertEqual(spy.count(), 1) 
    675675 
    676     def notestOnEmptyFit(self): 
     676    def testOnEmptyFit(self): 
    677677        """ 
    678678        Test a 1D/2D fit with no parameters 
     
    687687        self.widget.cbCategory.setCurrentIndex(category_index) 
    688688 
    689         #self.widget.show() 
     689        self.widget.show() 
    690690 
    691691        # Test no fitting params 
     
    698698        self.widget.close() 
    699699 
     700    def testOnEmptyFit2(self): 
    700701        test_data = Data2D(image=[1.0, 2.0, 3.0], 
    701702                           err_image=[0.01, 0.02, 0.03], 
     
    708709        item = QtGui.QStandardItem() 
    709710        updateModelItem(item, test_data, "test") 
     711 
    710712        # Force same data into logic 
    711713        self.widget.data = item 
     
    723725        self.assertTrue(logging.error.called_once()) 
    724726        self.assertTrue(logging.error.called_with('no fitting parameters')) 
    725         #self.widget.close() 
    726  
     727        self.widget.close() 
    727728 
    728729    def notestOnFit1D(self): 
     
    853854        self.assertIn("magnetism.html", self.widget.parent.showHelp.call_args[0][0]) 
    854855 
    855     def notestReadFitPage(self): 
     856    def testReadFitPage(self): 
    856857        """ 
    857858        Read in the fitpage object and restore state 
     
    859860        # Set data 
    860861        test_data = Data1D(x=[1,2], y=[1,2]) 
    861  
     862        item = QtGui.QStandardItem() 
     863        updateModelItem(item, test_data, "test") 
    862864        # Force same data into logic 
    863         self.widget.logic.data = test_data 
    864         self.widget.data_is_loaded = True 
     865        self.widget.data = item 
     866 
     867        # Force same data into logic 
    865868        category_index = self.widget.cbCategory.findText('Sphere') 
     869 
    866870        self.widget.cbCategory.setCurrentIndex(category_index) 
    867871        self.widget.main_params_to_fit = ['scale'] 
     
    939943        self.assertTrue(self.widget.tabFitting.isTabEnabled(4)) 
    940944 
    941     def notestCurrentState(self): 
     945    def testCurrentState(self): 
    942946        """ 
    943947        Set up the fitpage with current state 
     
    945949        # Set data 
    946950        test_data = Data1D(x=[1,2], y=[1,2]) 
    947  
     951        item = QtGui.QStandardItem() 
     952        updateModelItem(item, test_data, "test") 
    948953        # Force same data into logic 
    949         self.widget.logic.data = test_data 
    950         self.widget.data_is_loaded = True 
     954        self.widget.data = item 
    951955        category_index = self.widget.cbCategory.findText("Sphere") 
    952956        self.widget.cbCategory.setCurrentIndex(category_index) 
     
    964968        self.assertListEqual(fp.main_params_to_fit, ['scale']) 
    965969 
    966     def notestPushFitPage(self): 
     970    def testPushFitPage(self): 
    967971        """ 
    968972        Push current state of fitpage onto stack 
     
    970974        # Set data 
    971975        test_data = Data1D(x=[1,2], y=[1,2]) 
    972  
     976        item = QtGui.QStandardItem() 
     977        updateModelItem(item, test_data, "test") 
    973978        # Force same data into logic 
    974         self.widget.logic.data = test_data 
    975         self.widget.data_is_loaded = True 
     979        self.widget.data = item 
    976980        category_index = self.widget.cbCategory.findText("Sphere") 
    977981 
Note: See TracChangeset for help on using the changeset viewer.