Changeset fde5bcd in sasview for src/sas/qtgui/Perspectives


Ignore:
Timestamp:
Feb 28, 2018 6:04:56 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:
91ad45c
Parents:
c3eb858
Message:

Fixed issue with unwanted headers

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

Legend:

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

    r4992ff2 rfde5bcd  
    1 from copy import deepcopy 
     1import copy 
    22 
    33from PyQt5 import QtCore 
     
    159159        model.setHeaderData(i, QtCore.Qt.Horizontal, item) 
    160160 
    161     model.header_tooltips = model_header_tooltips 
     161    model.header_tooltips = copy.copy(model_header_tooltips) 
    162162 
    163163def addErrorHeadersToModel(model): 
     
    165165    Adds predefined headers to the model 
    166166    """ 
    167     model_header_error_captions = model_header_captions 
     167    model_header_error_captions = copy.copy(model_header_captions) 
    168168    model_header_error_captions.insert(2, header_error_caption) 
    169169    for i, item in enumerate(model_header_error_captions): 
    170170        model.setHeaderData(i, QtCore.Qt.Horizontal, item) 
    171171 
    172     model_header_error_tooltips = model_header_tooltips 
     172    model_header_error_tooltips = copy.copy(model_header_tooltips) 
    173173    model_header_error_tooltips.insert(2, error_tooltip) 
    174     model.header_tooltips = model_header_error_tooltips 
     174    model.header_tooltips = copy.copy(model_header_error_tooltips) 
    175175 
    176176def addPolyHeadersToModel(model): 
     
    181181        model.setHeaderData(i, QtCore.Qt.Horizontal, item) 
    182182 
    183     model.header_tooltips = poly_header_tooltips 
     183    model.header_tooltips = copy.copy(poly_header_tooltips) 
    184184 
    185185 
     
    188188    Adds predefined headers to the model 
    189189    """ 
    190     poly_header_error_captions = poly_header_captions 
     190    poly_header_error_captions = copy.copy(poly_header_captions) 
    191191    poly_header_error_captions.insert(2, header_error_caption) 
    192192    for i, item in enumerate(poly_header_error_captions): 
    193193        model.setHeaderData(i, QtCore.Qt.Horizontal, item) 
    194194 
    195     poly_header_error_tooltips = poly_header_tooltips 
     195    poly_header_error_tooltips = copy.copy(poly_header_tooltips) 
    196196    poly_header_error_tooltips.insert(2, error_tooltip) 
    197     model.header_tooltips = poly_header_error_tooltips 
     197    model.header_tooltips = copy.copy(poly_header_error_tooltips) 
    198198 
    199199def addShellsToModel(parameters, model, index): 
     
    271271            ## Set consistently w/AbstractFitengine: 
    272272            # But this should be corrected later. 
    273             dy = deepcopy(current_data.dy) 
     273            dy = copy.deepcopy(current_data.dy) 
    274274            dy[dy == 0] = 1 
    275275        fn = current_data.y[index] 
     
    369369    Create Data1D/Data2D with residuals, ready for plotting 
    370370    """ 
    371     data_copy = deepcopy(current_data) 
     371    data_copy = copy.deepcopy(current_data) 
    372372    # Get data: data I, theory I, and data dI in order 
    373373    method_name = current_data.__class__.__name__ 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    rc3eb858 rfde5bcd  
    13201320 
    13211321        # switch off reponse to model change 
    1322         self._model_model.blockSignals(True) 
    13231322        self._model_model.insertColumn(2, error_column) 
    1324         self._model_model.blockSignals(False) 
    13251323        FittingUtilities.addErrorHeadersToModel(self._model_model) 
    13261324        # Adjust the table cells width. 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingUtilitiesTest.py

    r53c771e rfde5bcd  
    11import sys 
    22import unittest 
    3 from PyQt5 import QtGui 
     3from PyQt5 import QtGui, QtCore 
    44 
    55from sas.qtgui.Plotting.PlotterData import Data1D 
     
    266266            chi = FittingUtilities.calculateChi2(reference_data, current_data) 
    267267 
     268    def notestAddHeadersToModel(self): 
     269        '''Check to see if headers are correctly applied''' 
     270        #test model 
     271        model = QtGui.QStandardItemModel() 
     272        FittingUtilities.addHeadersToModel(model) 
     273 
     274        # Assure we have properly named columns 
     275        names = FittingUtilities.model_header_captions 
     276        names_from_model = [model.headerData(i, QtCore.Qt.Horizontal) for i in range(len(names))] 
     277        self.assertEqual(names, names_from_model) 
     278 
     279        # Add another model 
     280        model2 = QtGui.QStandardItemModel() 
     281        # Add headers again 
     282        FittingUtilities.addHeadersToModel(model2) 
     283        # We still should have only the original names 
     284        names_from_model2 = [model2.headerData(i, QtCore.Qt.Horizontal) for i in range(len(names))] 
     285        self.assertEqual(names, names_from_model2) 
     286 
     287 
    268288if __name__ == "__main__": 
    269289    unittest.main() 
  • src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py

    rd6b8a1d rfde5bcd  
    8484            editor.setValidator(validator) 
    8585            return editor 
    86         if index.column() in [self.param_property, self.param_error]: 
     86        if index.column() in [self.param_property, self.param_error, self.param_unit]: 
    8787            # Set some columns uneditable 
    8888            return None 
Note: See TracChangeset for help on using the changeset viewer.