Changeset 7c487846 in sasview


Ignore:
Timestamp:
Nov 14, 2017 4:04:41 AM (6 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:
fa81e94
Parents:
f1f3e6a
Message:

Fixes to the Invariant perspective

Location:
src/sas/qtgui
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/GUITests.py

    r53c771e r7c487846  
    4949 
    5050# Perspectives 
    51 #import path_prepare 
     51#  Fitting 
    5252from Perspectives.Fitting.UnitTesting import FittingWidgetTest 
    5353from Perspectives.Fitting.UnitTesting import FittingPerspectiveTest 
     
    5656from Perspectives.Fitting.UnitTesting import FitPageTest 
    5757from Perspectives.Fitting.UnitTesting import FittingOptionsTest 
     58#  Invariant 
     59from Perspectives.Invariant.UnitTesting import InvariantPerspectiveTest 
     60from Perspectives.Invariant.UnitTesting import InvariantDetailsTest 
     61 
    5862 
    5963def suite(): 
     
    100104 
    101105        # Perspectives 
     106        #  Fitting 
    102107        unittest.makeSuite(FittingPerspectiveTest.FittingPerspectiveTest, 'test'), 
    103108        unittest.makeSuite(FittingWidgetTest.FittingWidgetTest,           'test'), 
     
    106111        unittest.makeSuite(FitPageTest.FitPageTest,                       'test'), 
    107112        unittest.makeSuite(FittingOptionsTest.FittingOptionsTest,         'test'), 
     113        #  Invariant 
     114        unittest.makeSuite(InvariantPerspectiveTest.InvariantPerspectiveTest,  'test'), 
     115        unittest.makeSuite(InvariantDetailsTest.InvariantDetailsTest,     'test'), 
    108116     ) 
    109117    return unittest.TestSuite(suites) 
  • src/sas/qtgui/MainWindow/GuiManager.py

    rd6b8a1d r7c487846  
    194194        if self._current_perspective: 
    195195            self._current_perspective.setClosable() 
     196            #self._workspace.workspace.removeSubWindow(self._current_perspective) 
    196197            self._current_perspective.close() 
     198            self._workspace.workspace.removeSubWindow(self._current_perspective) 
    197199        # Default perspective 
    198200        self._current_perspective = Perspectives.PERSPECTIVES[str(perspective_name)](parent=self) 
  • src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py

    r4992ff2 r7c487846  
    9191        """ 
    9292        # Invoke fit page events 
    93         for tab in self.tabs: 
    94             tab.close() 
    9593        if self._allow_close: 
    9694            # reset the closability flag 
    9795            self.setClosable(value=False) 
     96            # Tell the MdiArea to close the container 
     97            self.parentWidget().close() 
    9898            event.accept() 
    9999        else: 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r53c771e r7c487846  
    137137        if data is not None: 
    138138            self.data = data 
    139  
    140     #def close(self): 
    141     #    """ 
    142     #    Remember to kill off things on exit 
    143     #    """ 
    144     #    self.helpView.close() 
    145     #    del self.helpView 
    146139 
    147140    @property 
  • src/sas/qtgui/Perspectives/Invariant/InvariantDetails.py

    rf1f3e6a r7c487846  
    8181        self.txtQDataErr.setText(self._model.item(WIDGETS.W_INVARIANT_ERR).text()) 
    8282 
     83        # Reset progress counters 
     84        self.progress_low_qstar = 0.0 
     85        self.progress_high_qstar = 0.0 
     86        self.progress_qstar = 100.0 
     87 
    8388        # Low-Q 
    8489        if self._model.item(WIDGETS.W_ENABLE_LOWQ).text() == "true": 
     
    147152        if self.progress_qstar == 'error': 
    148153            msg += 'Error occurred when computing invariant from data.\n ' 
    149         if self.progress_qstar > 100: 
    150             msg += "Invariant Q contribution is greater than 100% .\n" 
     154        try: 
     155            if float(self.progress_qstar) > 100: 
     156                msg += "Invariant Q contribution is greater than 100% .\n" 
     157        except ValueError: 
     158            # Text message, skip msg update 
     159            pass 
    151160 
    152161        if self.progress_low_qstar == 'error': 
  • src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py

    rf1f3e6a r7c487846  
    125125        self.setupMapper() 
    126126 
     127        # Default enablement 
     128        self.cmdCalculate.setEnabled(False) 
     129 
    127130        # validator: double 
    128         self.txtBackgd.setValidator(QtGui.QDoubleValidator()) 
    129         self.txtContrast.setValidator(QtGui.QDoubleValidator()) 
    130         self.txtScale.setValidator(QtGui.QDoubleValidator()) 
    131         self.txtPorodCst.setValidator(QtGui.QDoubleValidator()) 
     131        self.txtBackgd.setValidator(GuiUtils.DoubleValidator()) 
     132        self.txtContrast.setValidator(GuiUtils.DoubleValidator()) 
     133        self.txtScale.setValidator(GuiUtils.DoubleValidator()) 
     134        self.txtPorodCst.setValidator(GuiUtils.DoubleValidator()) 
    132135 
    133136        # validator: integer number 
    134         valid_regex_int = QtCore.QRegExp('^[+]?(\d+[.][0]*)$') 
    135         self.txtNptsLowQ.setValidator(QtGui.QRegExpValidator(valid_regex_int, 
    136                                                              self.txtNptsLowQ)) 
    137         self.txtNptsHighQ.setValidator(QtGui.QRegExpValidator(valid_regex_int, 
    138                                                              self.txtNptsHighQ)) 
    139         self.txtPowerLowQ.setValidator(QtGui.QRegExpValidator(valid_regex_int, 
    140                                                              self.txtPowerLowQ)) 
    141         self.txtPowerHighQ.setValidator(QtGui.QRegExpValidator(valid_regex_int, 
    142                                                              self.txtPowerHighQ)) 
     137        self.txtNptsLowQ.setValidator(QtGui.QIntValidator()) 
     138        self.txtNptsHighQ.setValidator(QtGui.QIntValidator()) 
     139        self.txtPowerLowQ.setValidator(GuiUtils.DoubleValidator()) 
     140        self.txtPowerHighQ.setValidator(GuiUtils.DoubleValidator()) 
    143141 
    144142    def enabling(self): 
     
    159157            # reset the closability flag 
    160158            self.setClosable(value=False) 
     159            # Tell the MdiArea to close the container 
     160            self.parentWidget().close() 
    161161            event.accept() 
    162162        else: 
     
    227227 
    228228        self.model = model 
    229         self.mapper.toFirst() 
    230229        self._data = GuiUtils.dataFromItem(self._model_item) 
    231230 
     
    331330 
    332331        if (calculation_failed): 
    333             self.mapper.toFirst() 
    334332            logging.warning('Calculation failed: {}'.format(msg)) 
    335333            return self.model 
     
    416414            self.model.setItem(WIDGETS.D_HIGH_QSTAR_ERR, item) 
    417415 
    418             self.mapper.toFirst() 
    419  
    420416            return self.model 
    421417 
     
    504500        Error if it is larger than the distribution length 
    505501        """ 
     502        try: 
     503            int_value = int(self.sender().text()) 
     504        except ValueError: 
     505            self.sender().setStyleSheet(BG_RED) 
     506            self.cmdCalculate.setEnabled(False) 
     507            return 
     508 
    506509        if self._data: 
    507             if len(self._data.x) < int(self.sender().text()): 
    508                 self.sender().setStyleSheet(QtCore.QString(BG_RED)) 
     510            if len(self._data.x) < int_value: 
     511                self.sender().setStyleSheet(BG_RED) 
    509512                logging.warning('The number of points must be smaller than {}'.format(len(self._data.x))) 
    510513                self.cmdCalculate.setEnabled(False) 
    511514            else: 
    512                 self.sender().setStyleSheet(QtCore.QString(BG_WHITE)) 
     515                self.sender().setStyleSheet(BG_WHITE) 
    513516                self.cmdCalculate.setEnabled(True) 
    514517        else: 
     
    565568 
    566569        self.model.setItem(related_widgets[index_elt], item) 
    567  
    568         related_internal_values[index_elt] = float(self.sender().text()) 
    569  
    570         # print possible_senders[index_elt], related_internal_values[index_elt] 
    571  
    572         self.mapper.toFirst() 
     570        try: 
     571            related_internal_values[index_elt] = float(self.sender().text()) 
     572            self.sender().setStyleSheet(BG_WHITE) 
     573            self.cmdCalculate.setEnabled(True) 
     574        except ValueError: 
     575            # empty field, just skip 
     576            self.sender().setStyleSheet(BG_RED) 
     577            self.cmdCalculate.setEnabled(False) 
    573578 
    574579    def lowGuinierAndPowerToggle(self, toggle): 
     
    761766        # Extract data on 1st child - this is the Data1D/2D component 
    762767        data = GuiUtils.dataFromItem(self._model_item) 
    763         self.model.item(WIDGETS.W_FILENAME).setData(QtCore.QVariant(self._model_item.text())) 
     768        self.model.item(WIDGETS.W_FILENAME).setData(self._model_item.text()) 
    764769        # update GUI and model with info from loaded data 
    765770        self.updateGuiFromFile(data=data) 
  • src/sas/qtgui/Perspectives/Invariant/UnitTesting/InvariantDetailsTest.py

    rf1f3e6a r7c487846  
    88from PyQt5.QtTest import QTest 
    99from PyQt5.QtCore import Qt 
    10 from mock import MagicMock 
    11 from mock import patch 
     10from unittest.mock import MagicMock 
     11from unittest.mock import patch 
    1212 
    1313from twisted.internet import threads 
     
    138138        self.widget.qstar_total = 10 
    139139        self.widget.progress_qstar = 'error' 
    140         self.assertEqual(self.widget.checkValues(), "Error occurred when computing invariant from data.\n Invariant Q contribution is greater than 100% .\n") 
     140        self.assertIn("Error occurred when computing invariant from data.", self.widget.checkValues()) 
    141141 
    142142        self.widget.progress_qstar = 0 
  • src/sas/qtgui/Perspectives/Invariant/UnitTesting/InvariantPerspectiveTest.py

    rf1f3e6a r7c487846  
    88from PyQt5.QtTest import QTest 
    99from PyQt5.QtCore import Qt 
    10 from mock import MagicMock 
    11 from mock import patch 
    12 from mock import create_autospec 
     10from unittest.mock import MagicMock 
     11from unittest.mock import patch 
     12from unittest.mock import create_autospec 
    1313 
    1414from twisted.internet import threads 
     
    2323import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    2424 
    25 if not QtWidgets.QApplication.instance(): 
    26     app = QtWidgets.QApplication(sys.argv) 
     25#if not QtWidgets.QApplication.instance(): 
     26app = QtWidgets.QApplication(sys.argv) 
    2727 
    2828BG_COLOR_ERR = 'background-color: rgb(244, 170, 164);' 
     
    142142 
    143143        # Validators 
    144         self.assertIsInstance(self.widget.txtNptsLowQ.validator(), QtGui.QRegExpValidator) 
    145         self.assertIsInstance(self.widget.txtNptsHighQ.validator(), QtGui.QRegExpValidator) 
    146         self.assertIsInstance(self.widget.txtPowerLowQ.validator(), QtGui.QRegExpValidator) 
    147         self.assertIsInstance(self.widget.txtPowerHighQ.validator(), QtGui.QRegExpValidator) 
    148  
    149         self.assertIsInstance(self.widget.txtBackgd.validator(), QtGui.QDoubleValidator) 
    150         self.assertIsInstance(self.widget.txtContrast.validator(), QtGui.QDoubleValidator) 
    151         self.assertIsInstance(self.widget.txtScale.validator(), QtGui.QDoubleValidator) 
    152         self.assertIsInstance(self.widget.txtPorodCst.validator(), QtGui.QDoubleValidator) 
     144        self.assertIsInstance(self.widget.txtNptsLowQ.validator(), QtGui.QIntValidator) 
     145        self.assertIsInstance(self.widget.txtNptsHighQ.validator(), QtGui.QIntValidator) 
     146        self.assertIsInstance(self.widget.txtPowerLowQ.validator(), GuiUtils.DoubleValidator) 
     147        self.assertIsInstance(self.widget.txtPowerHighQ.validator(), GuiUtils.DoubleValidator) 
     148 
     149        self.assertIsInstance(self.widget.txtBackgd.validator(), GuiUtils.DoubleValidator) 
     150        self.assertIsInstance(self.widget.txtContrast.validator(), GuiUtils.DoubleValidator) 
     151        self.assertIsInstance(self.widget.txtScale.validator(), GuiUtils.DoubleValidator) 
     152        self.assertIsInstance(self.widget.txtPorodCst.validator(), GuiUtils.DoubleValidator) 
    153153 
    154154        # Test autoexclusivity of radiobuttons 
     
    202202        # self.assertEqual(self.widget._data.y[1], 4) 
    203203 
    204     def testHelp(self): 
     204    def notestHelp(self): 
    205205        """ Assure help file is shown """ 
    206206        # this should not rise 
Note: See TracChangeset for help on using the changeset viewer.