Changes in / [02226a2:259b116] in sasmodels


Ignore:
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • .travis.yml

    r5c36bf1 rf3767c2  
    99  - os: linux 
    1010    env: 
    11     - PY=3.6 
     11    - PY=3.7 
    1212  - os: osx 
    1313    language: generic 
     
    1717    language: generic 
    1818    env: 
    19     - PY=3.5 
     19    - PY=3.7 
    2020branches: 
    2121  only: 
  • sasmodels/convert.py

    r610ef23 r21c93c3  
    105105                    translation[newid+str(k)] = oldid+str(k) 
    106106    # Remove control parameter from the result 
    107     if model_info.control: 
    108         translation[model_info.control] = "CONTROL" 
     107    control_pars = [p.id for p in model_info.parameters.kernel_parameters 
     108                    if p.is_control] 
     109    if control_pars: 
     110        control_id = control_pars[0] 
     111        translation[control_id] = "CONTROL" 
    109112    return translation 
    110113 
  • sasmodels/modelinfo.py

    r39a06c9 r4f4d3e3  
    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`, 
  • sasmodels/product.py

    r99658f6 rb171acd  
    128128    # Remember the component info blocks so we can build the model 
    129129    model_info.composition = ('product', [p_info, s_info]) 
    130     model_info.control = p_info.control 
    131130    model_info.hidden = p_info.hidden 
    132131    if getattr(p_info, 'profile', None) is not None: 
  • sasmodels/sasview_model.py

    r3a1afed r21c93c3  
    253253 
    254254    # Process multiplicity 
     255    control_pars = [p.id for p in model_info.parameters.kernel_parameters 
     256                    if p.is_control] 
     257    control_id = 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_id: 
    260263            non_fittable.append(p.name) 
    261264            variants = MultiplicityInfo( 
     
    832835        """ 
    833836        if par.name not in self.params: 
    834             if par.name == self.multiplicity_info.control: 
     837            if par.id == self.multiplicity_info.control: 
    835838                return self.multiplicity, [self.multiplicity], [1.0] 
    836839            else: 
Note: See TracChangeset for help on using the changeset viewer.