Ignore:
Timestamp:
Sep 4, 2018 5:51:03 AM (6 years ago)
Author:
Torin Cooper-Bennun <torin.cooper-bennun@…>
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:
c7809a9
Parents:
00b7ddf0
git-author:
Torin Cooper-Bennun <torin.cooper-bennun@…> (08/17/18 11:51:05)
git-committer:
Torin Cooper-Bennun <torin.cooper-bennun@…> (09/04/18 05:51:03)
Message:

[CHERRY-PICK FROM 1547a91bc] handle duplicate names in P(Q)S(Q), using param item's internal data

File:
1 edited

Legend:

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

    r00b7ddf0 r700b03b  
    20602060        """ 
    20612061        structure_module = generate.load_kernel_module(structure_factor) 
    2062         structure_parameters = modelinfo.make_parameter_table(getattr(structure_module, 'parameters', [])) 
    2063  
    2064         structure_kernel = self.models[structure_factor]() 
    2065         form_kernel = self.kernel_module 
    2066  
    2067         self.kernel_module = MultiplicationModel(form_kernel, structure_kernel) 
     2062 
     2063        s_kernel = self.models[structure_factor]() 
     2064        p_kernel = self.kernel_module 
     2065 
     2066        p_pars_len = len(p_kernel._model_info.parameters.kernel_parameters) 
     2067        s_pars_len = len(s_kernel._model_info.parameters.kernel_parameters) - 1 # no radius_effective 
     2068 
     2069        self.kernel_module = MultiplicationModel(p_kernel, s_kernel) 
     2070 
     2071        # S(Q) params from the product model are not necessarily the same as those from the S(Q) model; any conflicting 
     2072        # names with P(Q) params will cause a rename; we also lose radius_effective (for now...) 
     2073        s_params = modelinfo.ParameterTable( 
     2074            self.kernel_module._model_info.parameters.kernel_parameters[p_pars_len:p_pars_len+s_pars_len]) 
     2075 
     2076        # These are the parameters before rename; ignore the first one, as it is radius_effective, which is removed 
     2077        # from the product model to be handled internally (for now...) 
     2078        s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters[1:]) 
    20682079 
    20692080        # Get new rows for QModel 
    2070         new_rows = FittingUtilities.addSimpleParametersToModel(structure_parameters, self.is2D) 
     2081        # Any renamed parameters are stored as data in the relevant item, for later handling 
     2082        new_rows = FittingUtilities.addSimpleParametersToModel(s_params, self.is2D, s_params_orig) 
     2083 
     2084        # TODO: deal with new parameter(s) added to product model, in kernel_parameters[p_pars_len+s_pars_len:] 
    20712085 
    20722086        # Add heading row 
     
    21082122        model_row = item.row() 
    21092123        name_index = self._model_model.index(model_row, 0) 
     2124        name_item = self._model_model.itemFromIndex(name_index) 
    21102125 
    21112126        # Extract changed value. 
     
    21162131            return 
    21172132 
    2118         parameter_name = str(self._model_model.data(name_index)) # sld, background etc. 
     2133        # if the item has user data, this is the actual parameter name (e.g. to handle duplicate names) 
     2134        if name_item.data(QtCore.Qt.UserRole): 
     2135            parameter_name = str(name_item.data(QtCore.Qt.UserRole)) 
     2136        else: 
     2137            parameter_name = str(self._model_model.data(name_index)) 
    21192138 
    21202139        # Update the parameter value - note: this supports +/-inf as well 
Note: See TracChangeset for help on using the changeset viewer.