Changeset 6c7ebb88 in sasview


Ignore:
Timestamp:
Mar 31, 2019 6:04:26 AM (5 years ago)
Author:
GitHub <noreply@…>
Parents:
f994f188 (diff), d32a594 (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.
git-author:
Adam Washington <rprospero@…> (03/31/19 06:04:26)
git-committer:
GitHub <noreply@…> (03/31/19 06:04:26)
Message:

Merge d32a594acc82ad29555832f498167b51564c75f3 into f994f188e28dca36e7823b2deb3bf2bfc351c35c

Files:
17 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Plotting/Plotter.py

    r6edd344 r6c7ebb88  
    9191            # make sure we have some function to operate on 
    9292            if self.data.xtransform is None: 
    93                 self.data.xtransform = 'log10(x)' 
     93                if self.data.isSesans: 
     94                    self.data.xtransform='x' 
     95                else: 
     96                    self.data.xtransform = 'log10(x)' 
    9497            if self.data.ytransform is None: 
    95                 self.data.ytransform = 'log10(y)' 
     98                if self.data.isSesans: 
     99                    self.data.ytransform='y' 
     100                else: 
     101                    self.data.ytransform = 'log10(y)' 
    96102            #Added condition to Dmax explorer from P(r) perspective 
    97103            if self.data._xaxis == 'D_{max}': 
  • src/sas/qtgui/Plotting/UnitTesting/PlotterTest.py

    r6edd344 r6c7ebb88  
    8181        """ Ensure that Sesans data is plotted in linear cooredinates""" 
    8282        data = Data1D(x=[1.0, 2.0, 3.0], 
    83                       y=[10.0, 11.0, 12.0], 
     83                      y=[-10.0, -11.0, -12.0], 
    8484                      dx=[0.1, 0.2, 0.3], 
    8585                      dy=[0.1, 0.2, 0.3]) 
     
    9797        self.assertEqual(self.plotter.ax.get_xscale(), 'linear') 
    9898        self.assertEqual(self.plotter.ax.get_yscale(), 'linear') 
     99        self.assertEqual(self.plotter.data.ytransform, "y") 
    99100        self.assertTrue(FigureCanvas.draw_idle.called) 
    100101 
  • build_tools/conda_qt5_min_osx.yml

    rb9a6546 r7a1481f  
    5050   - periodictable==1.5.0 
    5151   - bumps==0.7.11 
    52    - xhtml2pdf==0.2.2 
     52   - xhtml2pdf==0.2.3 
    5353   - qt5reactor==0.5 
    5454 
  • build_tools/conda_qt5_osx.yml

    r12dfce6 rf994f188  
    146146   - periodictable==1.5.0 
    147147   - bumps==0.7.11 
    148    - xhtml2pdf==0.2.2 
     148   - xhtml2pdf==0.2.3 
    149149   - qt5reactor==0.5 
  • src/sas/qtgui/Calculators/UnitTesting/GenericScatteringCalculatorTest.py

    r8137a02 rc02721c4  
    186186        # wait a bit for data to be loaded 
    187187        time.sleep(0.1) 
     188        QtWidgets.qApp.processEvents() 
     189 
    188190        # check updated values in ui, read from loaded file 
    189191        self.assertEqual(self.widget.txtData.text(), 'sld_file.sld') 
     
    250252 
    251253        time.sleep(1) 
     254        QtWidgets.qApp.processEvents() 
     255 
    252256        # check updated values in ui, read from loaded file 
    253257        # TODO to be changed 
     
    310314        self.assertEqual(self.widget.cmdLoad.text(), 'Loading...') 
    311315        time.sleep(2) 
     316        QtWidgets.qApp.processEvents() 
    312317 
    313318        self.assertEqual(self.widget.txtData.text(), 'A_Raw_Example-1.omf') 
     
    396401        self.assertEqual(self.widget.cmdLoad.text(), 'Loading...') 
    397402        time.sleep(1) 
     403        QtWidgets.qApp.processEvents() 
    398404 
    399405        self.assertTrue(self.widget.cmdDraw.isEnabled()) 
     
    417423 
    418424        time.sleep(0.1) 
     425        QtWidgets.qApp.processEvents() 
    419426 
    420427        filename1 = "test" 
    421428        QtWidgets.QFileDialog.getSaveFileName = MagicMock(return_value=[filename1, '']) 
    422429 
    423         QTest.mouseClick(self.widget.cmdSave, Qt.LeftButton) 
     430        #QTest.mouseClick(self.widget.cmdSave, Qt.LeftButton) 
    424431        self.widget.onSaveFile() 
     432        QtWidgets.qApp.processEvents() 
     433 
    425434        self.assertTrue(os.path.isfile(filename1 + '.sld')) 
    426435        self.assertTrue(os.path.getsize(filename1 + '.sld') > 0) 
  • src/sas/qtgui/Calculators/UnitTesting/SLDCalculatorTest.py

    r9ce69ec r6edd344  
    1313 
    1414# Local 
    15 from sas.qtgui.Calculators.SldPanel import SldResult 
     15#from sas.qtgui.Calculators.SldPanel import SldResult 
    1616from sas.qtgui.Calculators.SldPanel import SldPanel 
    17 from sas.qtgui.Calculators.SldPanel import sldAlgorithm 
     17from sas.qtgui.Calculators.SldPanel import neutronSldAlgorithm, xraySldAlgorithm 
    1818from sas.qtgui.Utilities.GuiUtils import FormulaValidator 
    1919 
     
    2222if not QtWidgets.QApplication.instance(): 
    2323    app = QtWidgets.QApplication(sys.argv) 
    24  
    25 class SldResultTest(unittest.TestCase): 
    26     """ Test the simple container class""" 
    27     def testObjectSize(self): 
    28         results = SldResult(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 
    29                             0.0, 0.0, 0.0, 0.0, 0.0, 0.0) 
    30         self.assertEqual(sys.getsizeof(results), 56) 
    3124 
    3225 
     
    3831        wavelength = 6.0 
    3932         
    40         results = sldAlgorithm( molecular_formula, 
     33        results = neutronSldAlgorithm( molecular_formula, 
    4134                                mass_density, 
    4235                                wavelength) 
    43         self.assertIsInstance(results, SldResult) 
     36        #self.assertIsInstance(results, SldResult) 
    4437        self.assertAlmostEqual(results.neutron_length, 0.175463, 5) 
    4538        self.assertAlmostEqual(results.neutron_inc_xs, 5.365857, 5) 
     
    5144        wavelength = 666.0 
    5245         
    53         results = sldAlgorithm( molecular_formula, 
     46        results = neutronSldAlgorithm( molecular_formula, 
    5447                                mass_density, 
    5548                                wavelength) 
    56         self.assertIsInstance(results, SldResult) 
     49        #self.assertIsInstance(results, SldResult) 
    5750        self.assertAlmostEqual(results.neutron_length,   0.059402, 5) 
    5851        self.assertAlmostEqual(results.neutron_inc_xs,   0.145427, 5) 
     
    128121 
    129122        # Assure the mass density field is set 
    130         #self.assertEqual(self.widget.ui.editNeutronIncXs.text(), '43.4') 
    131123        self.assertEqual(self.widget.ui.editNeutronIncXs.text(), '2.89') 
    132  
    133         # Reset the widget 
    134         self.widget.modelReset() 
    135         
    136         self.assertEqual(self.widget.ui.editMolecularFormula.text(), "H2O") 
    137         self.assertEqual(self.widget.ui.editMassDensity.text(), "1") 
    138         self.assertEqual(self.widget.ui.editWavelength.text(), "6") 
    139124 
    140125    def testHelp(self): 
  • src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py

    r0989bad rc02721c4  
    740740                                caption="Save As", 
    741741                                directory='cyl_400_20_out.txt', 
    742                                 filter='Text files (*.txt);;CanSAS 1D files(*.xml)', 
     742                                filter='Text files (*.txt);;CanSAS 1D files(*.xml);;NXcanSAS files (*.h5)', 
    743743                                parent=None) 
    744744        QFileDialog.getSaveFileName.assert_called_once() 
     
    763763                                caption="Save As", 
    764764                                directory='P123_D2O_10_percent_out.dat', 
    765                                 filter='IGOR/DAT 2D file in Q_map (*.dat)', 
     765                                filter='IGOR/DAT 2D file in Q_map (*.dat);;NXcanSAS files (*.h5)', 
    766766                                parent=None) 
    767767        QFileDialog.getSaveFileName.assert_called_once() 
  • src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py

    r0989bad rc02721c4  
    147147        """ 
    148148        self.manager.processVersion = MagicMock() 
    149         version = {'version'     : '4.2.0', 
     149        version = {'version'     : '4.2.1', 
    150150                   'update_url'  : 'http://www.sasview.org/sasview.latestversion',  
    151151                   'download_url': 'https://github.com/SasView/sasview/releases'} 
  • src/sas/qtgui/Perspectives/Fitting/ComplexConstraint.py

    rcf9f39e r460bdf4  
    150150        param2 = self.cbParam2.currentText() 
    151151        if source == "cbParam1": 
    152             self.txtParam.setText(self.tab_names[0] + ":" + param1) 
     152            self.txtParam.setText(self.cbModel1.currentText() + ":" + param1) 
    153153        else: 
    154             self.txtConstraint.setText(self.tab_names[1] + "." + param2) 
     154            self.txtConstraint.setText(self.cbModel2.currentText() + "." + param2) 
    155155        # Check if any of the parameters are polydisperse 
    156156        params_list = [param1, param2] 
  • src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py

    r14e1ff0 r770c42c  
    432432        """ 
    433433        item = self.tblConstraints.item(row, column) 
    434         if column != 0: return 
    435         # Update the tabs for fitting list 
    436         constraint = self.available_constraints[row] 
    437         constraint.active = (item.checkState() == QtCore.Qt.Checked) 
     434        if column == 0: 
     435            # Update the tabs for fitting list 
     436            constraint = self.available_constraints[row] 
     437            constraint.active = (item.checkState() == QtCore.Qt.Checked) 
     438            return 
    438439        # Update the constraint formula 
    439440        constraint = self.available_constraints[row] 
     
    470471        self.cmdFit.setStyleSheet('QPushButton {color: black;}') 
    471472        self.cmdFit.setText("Fit") 
     473        self.is_running = False 
    472474 
    473475        # Notify the parent about completed fitting 
     
    515517        self.cmdFit.setStyleSheet('QPushButton {color: black;}') 
    516518        self.cmdFit.setText("Fit") 
     519        self.is_running = False 
    517520 
    518521        # Notify the parent about completed fitting 
     
    549552        self.cmdFit.setStyleSheet('QPushButton {color: black;}') 
    550553        self.cmdFit.setText("Fit") 
     554        self.is_running = False 
    551555 
    552556        # Notify the parent about completed fitting 
     
    769773            item = self.uneditableItem(label) 
    770774            item = QtWidgets.QTableWidgetItem(label) 
    771             item.setFlags(item.flags() ^ QtCore.Qt.ItemIsUserCheckable) 
     775            # Why was this set to non-interactive?? 
     776            #item.setFlags(item.flags() ^ QtCore.Qt.ItemIsUserCheckable) 
    772777            item.setCheckState(QtCore.Qt.Checked) 
    773778            self.tblConstraints.insertRow(pos) 
  • src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py

    rf5e2a10a rc7e73e7  
    166166            if cbox: 
    167167                view.setIndexWidget(item2.index(), cbox) 
     168 
    168169        rows.append(row) 
    169170 
     
    202203        item1 = QtGui.QStandardItem(item_name) 
    203204        item1.setData(param.name, QtCore.Qt.UserRole) 
    204         item1.setCheckable(True) 
     205        item1.setCheckable(False) 
    205206        item1.setEditable(False) 
    206207 
     
    219220        # Append to the model and use the combobox, if required 
    220221        if None not in (model, view): 
     222 
    221223            if row_num is None: 
    222224                model.appendRow(row) 
     
    224226                model.insertRow(row_num, row) 
    225227                row_num += 1 
    226  
    227228            if cbox: 
     229                item1.setCheckable(False) 
     230                item3.setText("") 
     231                item4.setText("") 
     232                item3.setEditable(False) 
     233                item4.setEditable(False) 
    228234                view.setIndexWidget(item2.index(), cbox) 
     235            else: 
     236                item1.setCheckable(True) 
    229237 
    230238        rows.append(row) 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    rc149fba r73fb503  
    11611161        if category == CATEGORY_STRUCTURE: 
    11621162            model = None 
     1163        # copy original clipboard 
     1164        cb = QtWidgets.QApplication.clipboard() 
     1165        cb_text = cb.text() 
     1166        # get the screenshot of the current param state 
     1167        self.onCopyToClipboard("") 
    11631168 
    11641169        # Reset parameters to fit 
     
    11681173 
    11691174        self.respondToModelStructure(model=model, structure_factor=structure) 
     1175        # recast the original parameters into the model 
     1176        self.onParameterPaste() 
     1177        # revert to the original clipboard 
     1178        cb.setText(cb_text) 
    11701179 
    11711180    def resetParametersToFit(self): 
     
    20302039        if not self.data_is_loaded: 
    20312040            self.createDefaultDataset() 
     2041            self.smearing_widget.updateData(self.data) 
    20322042        self.calculateQGridForModel() 
    20332043 
     
    28702880        self.createNewIndex(weighted_data) 
    28712881 
    2872         # Plot residuals if actual data 
    2873         if not self.data_is_loaded: 
    2874             return 
    2875  
    28762882        # Calculate difference between return_data and logic.data 
    28772883        self.chi2 = FittingUtilities.calculateChi2(weighted_data, self.data) 
     
    28792885        chi2_repr = "---" if self.chi2 is None else GuiUtils.formatNumber(self.chi2, high=True) 
    28802886        self.lblChi2Value.setText(chi2_repr) 
     2887 
     2888        # Plot residuals if actual data 
     2889        if not self.data_is_loaded: 
     2890            return 
    28812891 
    28822892        residuals_plot = FittingUtilities.plotResiduals(self.data, weighted_data) 
  • src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py

    r17e6a2b rdc3b34e  
    173173            self.rbWeighting2.setEnabled(True) 
    174174            self.rbWeighting2.setChecked(True) 
     175            self.onWeightingChoice(self.rbWeighting2) 
    175176        else: 
    176177            self.rbWeighting2.setEnabled(False) 
    177178            self.rbWeighting1.setChecked(True) 
     179            self.onWeightingChoice(self.rbWeighting1) 
    178180 
    179181    def updateQRange(self, q_range_min, q_range_max, npts): 
  • src/sas/qtgui/Perspectives/Fitting/SmearingWidget.py

    ra5f7bf4 r73fb503  
    6464        self.kernel_model = None 
    6565        # dQ data variables 
    66         smear_type = None 
    67         dq_l = None 
    68         dq_r = None 
     66        self.smear_type = None 
     67        self.dq_l = None 
     68        self.dq_r = None 
     69 
     70        # current pinhole/slot values 
     71        self.pinhole = 0.0 
     72        self.slit_height = 0.0 
     73        self.slit_width = 0.0 
     74 
    6975        # Let only floats in the line edits 
    7076        self.txtSmearDown.setValidator(GuiUtils.DoubleValidator()) 
     
    109115        Update control elements based on data and model passed 
    110116        """ 
     117        # retain the index 
     118        cur_index = self.cbSmearing.currentIndex() 
    111119        self.cbSmearing.clear() 
    112120        self.cbSmearing.addItem("None") 
     
    117125        model = self.kernel_model 
    118126        self.updateKernelModel(model) 
     127        # already has the required setup so modify the index 
     128        self.cbSmearing.setCurrentIndex(cur_index) 
    119129 
    120130    def updateKernelModel(self, kernel_model=None): 
     
    184194        # Recalculate the smearing 
    185195        index = self.cbSmearing.currentIndex() 
     196        ## update the backup values based on model choice 
     197        smearing, accuracy, d_down, d_up = self.state() 
     198        # don't save the state if dQ Data 
     199        if smearing == "Custom Pinhole Smear": 
     200            self.pinhole = d_down 
     201            self.accuracy = accuracy 
     202        elif smearing == 'Custom Slit Smear': 
     203            self.slit_height = d_up 
     204            self.slit_width = d_down 
     205 
    186206        self.onIndexChange(index) 
    187207 
     
    221241            self.lblSmearUp.setText('<html><head/><body><p>dQ/Q</p></body></html>') 
    222242            self.lblUnitUp.setText('%') 
     243        self.txtSmearUp.setText(str(self.pinhole)) 
     244 
    223245        self.txtSmearDown.setEnabled(True) 
    224246        self.txtSmearUp.setEnabled(True) 
     
    234256        self.lblUnitDown.setText('<html><head/><body><p>à
    235257<span style=" vertical-align:super;">-1</span></p></body></html>') 
     258        self.txtSmearDown.setText(str(self.slit_height)) 
     259        self.txtSmearUp.setText(str(self.slit_width)) 
    236260        self.txtSmearDown.setEnabled(True) 
    237261        self.txtSmearUp.setEnabled(True) 
     
    277301            accuracy = str(self.model.item(MODEL.index('ACCURACY')).text()) 
    278302            try: 
    279                 d_down = float(self.model.item(MODEL.index('PINHOLE_MIN')).text()) 
     303                d_down = float(self.txtSmearUp.text()) 
    280304            except ValueError: 
    281305                d_down = None 
    282306            try: 
    283                 d_up = float(self.model.item(MODEL.index('PINHOLE_MAX')).text()) 
     307                d_up = float(self.txtSmearDown.text()) 
    284308            except ValueError: 
    285309                d_up = None 
     
    292316        """ 
    293317        # Update the model -> controls update automatically 
    294         #if smearing is not None: 
    295             #self.model.item(MODEL.index('SMEARING')).setText(smearing) 
    296318        if accuracy is not None: 
    297319            self.model.item(MODEL.index('ACCURACY')).setText(accuracy) 
     
    347369        if d_height is None: 
    348370            d_height = 0.0 
     371 
     372        self.slit_width = d_width 
     373        self.slit_height = d_height 
    349374 
    350375        if isinstance(self.data, Data2D): 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py

    r0989bad r6edd344  
    205205        model_index = self.widget.cbModel.findText("be_polyelectrolyte") 
    206206        self.widget.cbModel.setCurrentIndex(model_index) 
     207        QtWidgets.qApp.processEvents() 
    207208 
    208209        # check the enablement of controls 
     
    242243        self.widget.show() 
    243244        # Change the category index so we have some models 
    244         category_index = self.widget.cbCategory.findText("Shape Independent") 
     245        category_index = self.widget.cbCategory.findText("Cylinder") 
    245246        self.widget.cbCategory.setCurrentIndex(category_index) 
    246247        # Change the model to one that supports structure factors 
    247         model_index = self.widget.cbModel.findText('fractal_core_shell') 
     248        model_index = self.widget.cbModel.findText('cylinder') 
    248249        self.widget.cbModel.setCurrentIndex(model_index) 
    249250 
     
    260261        self.widget.cbStructureFactor.setCurrentIndex(structure_index) 
    261262 
    262         # We have 3 more param rows now (radius_effective is removed), and a new heading 
    263         self.assertEqual(self.widget._model_model.rowCount(), rowcount+4) 
     263        # We have 3 more param rows now (radius_effective is removed), and new headings 
     264        self.assertEqual(self.widget._model_model.rowCount(), rowcount+7) 
    264265 
    265266        # Switch models 
     
    12291230        model_index = self.widget.cbModel.findText("pringle") 
    12301231        self.widget.cbModel.setCurrentIndex(model_index) 
     1232        QtWidgets.qApp.processEvents() 
    12311233 
    12321234        # make sure the parameters are different than before 
  • src/sas/qtgui/Plotting/PlotterBase.py

    r8fad50b rb016f17  
    111111        self.contextMenu = QtWidgets.QMenu(self) 
    112112        self.toolbar = NavigationToolbar(self.canvas, self) 
     113        cid = self.canvas.mpl_connect('resize_event', self.onResize) 
     114 
    113115        layout.addWidget(self.toolbar) 
    114116        if not quickplot: 
     
    244246        raise NotImplementedError("Context menu method must be implemented in derived class.") 
    245247 
     248    def onResize(self, event): 
     249        """ 
     250        Redefine default resize event 
     251        """ 
     252        pass 
     253 
    246254    def contextMenuEvent(self, event): 
    247255        """ 
  • src/sas/qtgui/Utilities/UnitTesting/TabbedModelEditorTest.py

    r80468f6 rc02721c4  
    204204        self.widget.editor_widget.txtEditor.toPlainText = MagicMock(return_value=boring_text) 
    205205        self.widget.writeFile = MagicMock() 
     206        self.widget.plugin_widget.is_python = MagicMock() 
    206207        #invoke the method 
    207208        self.widget.updateFromEditor() 
Note: See TracChangeset for help on using the changeset viewer.