Changeset 225bf94 in sasmodels for sasmodels/modelinfo.py


Ignore:
Timestamp:
Mar 13, 2019 12:26:42 PM (5 years ago)
Author:
GitHub <noreply@…>
Children:
0c86b79
Parents:
3b6567f (diff), d8eaa3d (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:
Paul Kienzle <pkienzle@…> (03/13/19 12:26:42)
git-committer:
GitHub <noreply@…> (03/13/19 12:26:42)
Message:

Merge branch 'beta_approx' into master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/modelinfo.py

    r3b6567f r225bf94  
    295295    example, might be used to set the value of a shape parameter. 
    296296 
    297     These values are set by :func:`make_parameter_table` and 
     297    Control parameters are used for variant models such as :ref:`rpa` which 
     298    have different cases with different parameters, as well as models 
     299    like :ref:`spherical_sld` with its user defined number of shells. 
     300    The control parameter should appear in the parameter table along with the 
     301    parameters it is is controlling.  For variant models, use *[CASES]* in 
     302    place of the parameter limits Within the parameter definition table, 
     303    with case names such as:: 
     304 
     305         CASES = ["diblock copolymer", "triblock copolymer", ...] 
     306 
     307    This should give *limits=[[case1, case2, ...]]*, but the model loader 
     308    translates it to *limits=[0, len(CASES)-1]*, and adds *choices=CASES* to 
     309    the :class:`Parameter` definition. Note that models can use a list of 
     310    cases as a parameter without it being a control parameter.  Either way, 
     311    the parameter is sent to the model evaluator as *float(choice_num)*, 
     312    where choices are numbered from 0. :meth:`ModelInfo.get_hidden_parameters` 
     313    will determine which parameers to display. 
     314 
     315    The class contructor should not be called directly, but instead the 
     316    parameter table is built using :func:`make_parameter_table` and 
    298317    :func:`parse_parameter` therein. 
    299318    """ 
     
    847866    info.sesans = getattr(kernel_module, 'sesans', None) # type: ignore 
    848867    info.random = getattr(kernel_module, 'random', None) 
    849  
    850     # multiplicity info 
    851     control_pars = [p.id for p in parameters.kernel_parameters if p.is_control] 
    852     default_control = control_pars[0] if control_pars else None 
    853     info.control = getattr(kernel_module, 'control', default_control) 
    854868    info.hidden = getattr(kernel_module, 'hidden', None) # type: ignore 
    855869 
     
    874888    info.opencl = getattr(kernel_module, 'opencl', not callable(info.Iq)) 
    875889    info.single = getattr(kernel_module, 'single', not callable(info.Iq)) 
     890     
     891    # Set control flag for explicitly set parameters, e.g., in the RPA model. 
     892    control = getattr(kernel_module, 'control', None) 
     893    if control is not None: 
     894        parameters[control].is_control = True 
    876895 
    877896    if callable(info.Iq) and parameters.has_2d: 
     
    924943    #: *sphere*hardsphere* or *cylinder+sphere*. 
    925944    composition = None      # type: Optional[Tuple[str, List[ModelInfo]]] 
    926     #: Name of the control parameter for a variant model such as :ref:`rpa`. 
    927     #: The *control* parameter should appear in the parameter table, with 
    928     #: limits defined as *[CASES]*, for case names such as 
    929     #: *CASES = ["diblock copolymer", "triblock copolymer", ...]*. 
    930     #: This should give *limits=[[case1, case2, ...]]*, but the 
    931     #: model loader translates this to *limits=[0, len(CASES)-1]*, and adds 
    932     #: *choices=CASES* to the :class:`Parameter` definition. Note that 
    933     #: models can use a list of cases as a parameter without it being a 
    934     #: control parameter.  Either way, the parameter is sent to the model 
    935     #: evaluator as *float(choice_num)*, where choices are numbered from 0. 
    936     #: See also :attr:`hidden`. 
    937     control = None          # type: str 
    938945    #: Different variants require different parameters.  In order to show 
    939946    #: just the parameters needed for the variant selected by :attr:`control`, 
     
    9991006    #: C code, either defined as a string, or in the sources. 
    10001007    shell_volume = None      # type: Union[None, str, Callable[[np.ndarray], float]] 
     1008    #: Computes the effective radius of the shape given the volume parameters. 
     1009    #: Only needed for models defined in python that can be used for 
     1010    #: monodisperse approximation for non-dilute solutions, P@S.  The first 
     1011    #: argument is the integer effective radius mode, with default 0. 
     1012    effective_radius = None  # type: Union[None, Callable[[int, np.ndarray], float]] 
    10011013    #: Returns *I(q, a, b, ...)* for parameters *a*, *b*, etc. defined 
    10021014    #: by the parameter table.  *Iq* can be defined as a python function, or 
     
    10101022    #: will return *I(q, a, b, ...)*.  Multiplicity parameters are sent as 
    10111023    #: pointers to doubles.  Constants in floating point expressions should 
    1012     #: include the decimal point. See :mod:`generate` for more details. 
     1024    #: include the decimal point. See :mod:`generate` for more details. If 
     1025    #: *have_Fq* is True, then Iq should return an interleaved array of 
     1026    #: $[\sum F(q_1), \sum F^2(q_1), \ldots, \sum F(q_n), \sum F^2(q_n)]$. 
    10131027    Iq = None               # type: Union[None, str, Callable[[np.ndarray], np.ndarray]] 
    10141028    #: Returns *I(qab, qc, a, b, ...)*.  The interface follows :attr:`Iq`. 
Note: See TracChangeset for help on using the changeset viewer.