Changeset 259b116 in sasmodels for sasmodels/modelinfo.py


Ignore:
Timestamp:
Mar 11, 2019 12:21:39 PM (5 years ago)
Author:
GitHub <noreply@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
aee8dfb
Parents:
02226a2 (diff), fd7291e (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/11/19 12:21:39)
git-committer:
GitHub <noreply@…> (03/11/19 12:21:39)
Message:

Merge pull request #95 from SasView?/ticket-1022-sum_multiplicity

Allow sum models with multiplicity

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/modelinfo.py

    rc1799d3 rfd7291e  
    290290    example, might be used to set the value of a shape parameter. 
    291291 
    292     These values are set by :func:`make_parameter_table` and 
     292    Control parameters are used for variant models such as :ref:`rpa` which 
     293    have different cases with different parameters, as well as models 
     294    like :ref:`spherical_sld` with its user defined number of shells. 
     295    The control parameter should appear in the parameter table along with the 
     296    parameters it is is controlling.  For variant models, use *[CASES]* in 
     297    place of the parameter limits Within the parameter definition table, 
     298    with case names such as:: 
     299 
     300         CASES = ["diblock copolymer", "triblock copolymer", ...] 
     301 
     302    This should give *limits=[[case1, case2, ...]]*, but the model loader 
     303    translates it to *limits=[0, len(CASES)-1]*, and adds *choices=CASES* to 
     304    the :class:`Parameter` definition. Note that models can use a list of 
     305    cases as a parameter without it being a control parameter.  Either way, 
     306    the parameter is sent to the model evaluator as *float(choice_num)*, 
     307    where choices are numbered from 0. :meth:`ModelInfo.get_hidden_parameters` 
     308    will determine which parameers to display. 
     309 
     310    The class contructor should not be called directly, but instead the 
     311    parameter table is built using :func:`make_parameter_table` and 
    293312    :func:`parse_parameter` therein. 
    294313    """ 
     
    845864    info.single = getattr(kernel_module, 'single', not callable(info.Iq)) 
    846865    info.random = getattr(kernel_module, 'random', None) 
    847  
    848     # multiplicity info 
    849     control_pars = [p.id for p in parameters.kernel_parameters if p.is_control] 
    850     default_control = control_pars[0] if control_pars else None 
    851     info.control = getattr(kernel_module, 'control', default_control) 
    852866    info.hidden = getattr(kernel_module, 'hidden', None) # type: ignore 
     867 
     868    # Set control flag for explicitly set parameters, e.g., in the RPA model. 
     869    control = getattr(kernel_module, 'control', None) 
     870    if control is not None: 
     871        parameters[control].is_control = True 
    853872 
    854873    if callable(info.Iq) and parameters.has_2d: 
     
    903922    #: *sphere*hardsphere* or *cylinder+sphere*. 
    904923    composition = None      # type: Optional[Tuple[str, List[ModelInfo]]] 
    905     #: Name of the control parameter for a variant model such as :ref:`rpa`. 
    906     #: The *control* parameter should appear in the parameter table, with 
    907     #: limits defined as *[CASES]*, for case names such as 
    908     #: *CASES = ["diblock copolymer", "triblock copolymer", ...]*. 
    909     #: This should give *limits=[[case1, case2, ...]]*, but the 
    910     #: model loader translates this to *limits=[0, len(CASES)-1]*, and adds 
    911     #: *choices=CASES* to the :class:`Parameter` definition. Note that 
    912     #: models can use a list of cases as a parameter without it being a 
    913     #: control parameter.  Either way, the parameter is sent to the model 
    914     #: evaluator as *float(choice_num)*, where choices are numbered from 0. 
    915     #: See also :attr:`hidden`. 
    916     control = None          # type: str 
    917924    #: Different variants require different parameters.  In order to show 
    918925    #: just the parameters needed for the variant selected by :attr:`control`, 
Note: See TracChangeset for help on using the changeset viewer.