Changeset 259b116 in sasmodels for sasmodels/modelinfo.py
- Timestamp:
- Mar 11, 2019 12:21:39 PM (5 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/modelinfo.py
rc1799d3 rfd7291e 290 290 example, might be used to set the value of a shape parameter. 291 291 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 293 312 :func:`parse_parameter` therein. 294 313 """ … … 845 864 info.single = getattr(kernel_module, 'single', not callable(info.Iq)) 846 865 info.random = getattr(kernel_module, 'random', None) 847 848 # multiplicity info849 control_pars = [p.id for p in parameters.kernel_parameters if p.is_control]850 default_control = control_pars[0] if control_pars else None851 info.control = getattr(kernel_module, 'control', default_control)852 866 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 853 872 854 873 if callable(info.Iq) and parameters.has_2d: … … 903 922 #: *sphere*hardsphere* or *cylinder+sphere*. 904 923 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, with907 #: limits defined as *[CASES]*, for case names such as908 #: *CASES = ["diblock copolymer", "triblock copolymer", ...]*.909 #: This should give *limits=[[case1, case2, ...]]*, but the910 #: model loader translates this to *limits=[0, len(CASES)-1]*, and adds911 #: *choices=CASES* to the :class:`Parameter` definition. Note that912 #: models can use a list of cases as a parameter without it being a913 #: control parameter. Either way, the parameter is sent to the model914 #: evaluator as *float(choice_num)*, where choices are numbered from 0.915 #: See also :attr:`hidden`.916 control = None # type: str917 924 #: Different variants require different parameters. In order to show 918 925 #: just the parameters needed for the variant selected by :attr:`control`,
Note: See TracChangeset
for help on using the changeset viewer.