Changeset b171acd in sasmodels
- Timestamp:
- Jan 29, 2019 1:54:28 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 4f4d3e3
- Parents:
- 15c80af
- Location:
- sasmodels
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/mixture.py
r15c80af rb171acd 34 34 # Build new parameter list 35 35 combined_pars = [] 36 control = None37 36 38 37 all_parts = copy(parts) … … 117 116 p.length_control = prefix + p.length_control 118 117 combined_pars.append(p) 119 if p.is_control and control is None:120 control = p.id121 118 parameters = ParameterTable(combined_pars) 122 119 parameters.max_pd = sum(part.parameters.max_pd for part in parts) … … 132 129 model_info = ModelInfo() 133 130 model_info.id = operation.join(part.id for part in parts) 134 model_info.control = control135 131 model_info.operation = operation 136 132 model_info.name = '(' + operation.join(part.name for part in parts) + ')' -
sasmodels/modelinfo.py
rbd547d0 rb171acd 291 291 example, might be used to set the value of a shape parameter. 292 292 293 These values are set by :func:`make_parameter_table` and 293 Control parameters are used for variant models such as :ref:`rpa` which 294 have different cases with different parameters, as well as models 295 like :ref:`spherical_sld` with its user defined number of shells. 296 The control parameter should appear in the parameter table along with the 297 parameters it is is controlling. For variant models, use *[CASES]* in 298 place of the parameter limits Within the parameter definition table, 299 with case names such as:: 300 301 CASES = ["diblock copolymer", "triblock copolymer", ...] 302 303 This should give *limits=[[case1, case2, ...]]*, but the model loader 304 translates it to *limits=[0, len(CASES)-1]*, and adds *choices=CASES* to 305 the :class:`Parameter` definition. Note that models can use a list of 306 cases as a parameter without it being a control parameter. Either way, 307 the parameter is sent to the model evaluator as *float(choice_num)*, 308 where choices are numbered from 0. :meth:`ModelInfo.get_hidden_parameters` 309 will determine which parameers to display. 310 311 The class contructor should not be called directly, but instead the 312 parameter table is built using :func:`make_parameter_table` and 294 313 :func:`parse_parameter` therein. 295 314 """ … … 813 832 info.single = getattr(kernel_module, 'single', not callable(info.Iq)) 814 833 info.random = getattr(kernel_module, 'random', None) 815 816 # multiplicity info817 control_pars = [p.id for p in parameters.kernel_parameters if p.is_control]818 default_control = control_pars[0] if control_pars else None819 info.control = getattr(kernel_module, 'control', default_control)820 834 info.hidden = getattr(kernel_module, 'hidden', None) # type: ignore 821 835 … … 872 886 #: *sphere*hardsphere* or *cylinder+sphere*. 873 887 composition = None # type: Optional[Tuple[str, List[ModelInfo]]] 874 #: Name of the control parameter for a variant model such as :ref:`rpa`.875 #: The *control* parameter should appear in the parameter table, with876 #: limits defined as *[CASES]*, for case names such as877 #: *CASES = ["diblock copolymer", "triblock copolymer", ...]*.878 #: This should give *limits=[[case1, case2, ...]]*, but the879 #: model loader translates this to *limits=[0, len(CASES)-1]*, and adds880 #: *choices=CASES* to the :class:`Parameter` definition. Note that881 #: models can use a list of cases as a parameter without it being a882 #: control parameter. Either way, the parameter is sent to the model883 #: evaluator as *float(choice_num)*, where choices are numbered from 0.884 #: See also :attr:`hidden`.885 control = None # type: str886 888 #: Different variants require different parameters. In order to show 887 889 #: just the parameters needed for the variant selected by :attr:`control`, -
sasmodels/product.py
r2d81cfe rb171acd 103 103 # Remember the component info blocks so we can build the model 104 104 model_info.composition = ('product', [p_info, s_info]) 105 model_info.control = p_info.control106 105 model_info.hidden = p_info.hidden 107 106 if getattr(p_info, 'profile', None) is not None: -
sasmodels/sasview_model.py
ra4f1a73 rb171acd 253 253 254 254 # Process multiplicity 255 control_pars = [p.id for p in model_info.parameters.kernel_parameters 256 if p.is_control] 257 control = control_pars[0] if control_pars else None 255 258 non_fittable = [] # type: List[str] 256 259 xlabel = model_info.profile_axes[0] if model_info.profile is not None else "" 257 260 variants = MultiplicityInfo(0, "", [], xlabel) 258 261 for p in model_info.parameters.kernel_parameters: 259 if p. name == model_info.control:262 if p.id == control: 260 263 non_fittable.append(p.name) 261 264 variants = MultiplicityInfo( … … 800 803 """ 801 804 if par.name not in self.params: 802 if par. name== self.multiplicity_info.control:805 if par.id == self.multiplicity_info.control: 803 806 return self.multiplicity, [self.multiplicity], [1.0] 804 807 else:
Note: See TracChangeset
for help on using the changeset viewer.