Changeset b171acd in sasmodels


Ignore:
Timestamp:
Jan 29, 2019 1:54:28 PM (3 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
4f4d3e3
Parents:
15c80af
Message:

move 'multiplicity' handling into sasview model. Refs #1022.

Location:
sasmodels
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/mixture.py

    r15c80af rb171acd  
    3434    # Build new parameter list 
    3535    combined_pars = [] 
    36     control = None 
    3736 
    3837    all_parts = copy(parts) 
     
    117116                p.length_control = prefix + p.length_control 
    118117            combined_pars.append(p) 
    119             if p.is_control and control is None: 
    120                 control = p.id 
    121118    parameters = ParameterTable(combined_pars) 
    122119    parameters.max_pd = sum(part.parameters.max_pd for part in parts) 
     
    132129    model_info = ModelInfo() 
    133130    model_info.id = operation.join(part.id for part in parts) 
    134     model_info.control = control 
    135131    model_info.operation = operation 
    136132    model_info.name = '(' + operation.join(part.name for part in parts) + ')' 
  • sasmodels/modelinfo.py

    rbd547d0 rb171acd  
    291291    example, might be used to set the value of a shape parameter. 
    292292 
    293     These values are set by :func:`make_parameter_table` and 
     293    Control parameters are used for variant models such as :ref:`rpa` which 
     294    have different cases with different parameters, as well as models 
     295    like :ref:`spherical_sld` with its user defined number of shells. 
     296    The control parameter should appear in the parameter table along with the 
     297    parameters it is is controlling.  For variant models, use *[CASES]* in 
     298    place of the parameter limits Within the parameter definition table, 
     299    with case names such as:: 
     300 
     301         CASES = ["diblock copolymer", "triblock copolymer", ...] 
     302 
     303    This should give *limits=[[case1, case2, ...]]*, but the model loader 
     304    translates it to *limits=[0, len(CASES)-1]*, and adds *choices=CASES* to 
     305    the :class:`Parameter` definition. Note that models can use a list of 
     306    cases as a parameter without it being a control parameter.  Either way, 
     307    the parameter is sent to the model evaluator as *float(choice_num)*, 
     308    where choices are numbered from 0. :meth:`ModelInfo.get_hidden_parameters` 
     309    will determine which parameers to display. 
     310 
     311    The class contructor should not be called directly, but instead the 
     312    parameter table is built using :func:`make_parameter_table` and 
    294313    :func:`parse_parameter` therein. 
    295314    """ 
     
    813832    info.single = getattr(kernel_module, 'single', not callable(info.Iq)) 
    814833    info.random = getattr(kernel_module, 'random', None) 
    815  
    816     # multiplicity info 
    817     control_pars = [p.id for p in parameters.kernel_parameters if p.is_control] 
    818     default_control = control_pars[0] if control_pars else None 
    819     info.control = getattr(kernel_module, 'control', default_control) 
    820834    info.hidden = getattr(kernel_module, 'hidden', None) # type: ignore 
    821835 
     
    872886    #: *sphere*hardsphere* or *cylinder+sphere*. 
    873887    composition = None      # type: Optional[Tuple[str, List[ModelInfo]]] 
    874     #: Name of the control parameter for a variant model such as :ref:`rpa`. 
    875     #: The *control* parameter should appear in the parameter table, with 
    876     #: limits defined as *[CASES]*, for case names such as 
    877     #: *CASES = ["diblock copolymer", "triblock copolymer", ...]*. 
    878     #: This should give *limits=[[case1, case2, ...]]*, but the 
    879     #: model loader translates this to *limits=[0, len(CASES)-1]*, and adds 
    880     #: *choices=CASES* to the :class:`Parameter` definition. Note that 
    881     #: models can use a list of cases as a parameter without it being a 
    882     #: control parameter.  Either way, the parameter is sent to the model 
    883     #: evaluator as *float(choice_num)*, where choices are numbered from 0. 
    884     #: See also :attr:`hidden`. 
    885     control = None          # type: str 
    886888    #: Different variants require different parameters.  In order to show 
    887889    #: just the parameters needed for the variant selected by :attr:`control`, 
  • sasmodels/product.py

    r2d81cfe rb171acd  
    103103    # Remember the component info blocks so we can build the model 
    104104    model_info.composition = ('product', [p_info, s_info]) 
    105     model_info.control = p_info.control 
    106105    model_info.hidden = p_info.hidden 
    107106    if getattr(p_info, 'profile', None) is not None: 
  • sasmodels/sasview_model.py

    ra4f1a73 rb171acd  
    253253 
    254254    # Process multiplicity 
     255    control_pars = [p.id for p in model_info.parameters.kernel_parameters 
     256                    if p.is_control] 
     257    control = control_pars[0] if control_pars else None 
    255258    non_fittable = []  # type: List[str] 
    256259    xlabel = model_info.profile_axes[0] if model_info.profile is not None else "" 
    257260    variants = MultiplicityInfo(0, "", [], xlabel) 
    258261    for p in model_info.parameters.kernel_parameters: 
    259         if p.name == model_info.control: 
     262        if p.id == control: 
    260263            non_fittable.append(p.name) 
    261264            variants = MultiplicityInfo( 
     
    800803        """ 
    801804        if par.name not in self.params: 
    802             if par.name == self.multiplicity_info.control: 
     805            if par.id == self.multiplicity_info.control: 
    803806                return self.multiplicity, [self.multiplicity], [1.0] 
    804807            else: 
Note: See TracChangeset for help on using the changeset viewer.