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


Ignore:
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • .travis.yml

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

    r21c93c3 r610ef23  
    105105                    translation[newid+str(k)] = oldid+str(k) 
    106106    # Remove control parameter from the result 
    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" 
     107    if model_info.control: 
     108        translation[model_info.control] = "CONTROL" 
    112109    return translation 
    113110 
  • sasmodels/modelinfo.py

    r4f4d3e3 r39a06c9  
    290290    example, might be used to set the value of a shape parameter. 
    291291 
    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 
     292    These values are set by :func:`make_parameter_table` and 
    312293    :func:`parse_parameter` therein. 
    313294    """ 
     
    864845    info.single = getattr(kernel_module, 'single', not callable(info.Iq)) 
    865846    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) 
    866852    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 
    872853 
    873854    if callable(info.Iq) and parameters.has_2d: 
     
    922903    #: *sphere*hardsphere* or *cylinder+sphere*. 
    923904    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 
    924917    #: Different variants require different parameters.  In order to show 
    925918    #: just the parameters needed for the variant selected by :attr:`control`, 
  • sasmodels/product.py

    rb171acd r99658f6  
    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 
    130131    model_info.hidden = p_info.hidden 
    131132    if getattr(p_info, 'profile', None) is not None: 
  • sasmodels/sasview_model.py

    r21c93c3 r3a1afed  
    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 
    258255    non_fittable = []  # type: List[str] 
    259256    xlabel = model_info.profile_axes[0] if model_info.profile is not None else "" 
    260257    variants = MultiplicityInfo(0, "", [], xlabel) 
    261258    for p in model_info.parameters.kernel_parameters: 
    262         if p.id == control_id: 
     259        if p.name == model_info.control: 
    263260            non_fittable.append(p.name) 
    264261            variants = MultiplicityInfo( 
     
    835832        """ 
    836833        if par.name not in self.params: 
    837             if par.id == self.multiplicity_info.control: 
     834            if par.name == self.multiplicity_info.control: 
    838835                return self.multiplicity, [self.multiplicity], [1.0] 
    839836            else: 
Note: See TracChangeset for help on using the changeset viewer.