Changeset bcdd6c9 in sasmodels
- Timestamp:
- Sep 1, 2017 4:56:43 AM (7 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 65314f7
- Parents:
- fb9a3b6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/sasview_model.py
r724257c rbcdd6c9 120 120 else: 121 121 model_info = modelinfo.make_model_info(kernel_module) 122 model = _make_model_from_info(model_info)122 model = make_model_from_info(model_info) 123 123 model.timestamp = getmtime(path) 124 124 … … 142 142 143 143 144 def make_model_from_info(model_info): 145 # type: (ModelInfo) -> SasviewModelType 146 """ 147 Convert *model_info* into a SasView model wrapper. 148 """ 149 def __init__(self, multiplicity=None): 150 SasviewModel.__init__(self, multiplicity=multiplicity) 151 attrs = _generate_model_attributes(model_info) 152 attrs['__init__'] = __init__ 153 attrs['filename'] = model_info.filename 154 ConstructedModel = type(model_info.name, (SasviewModel,), attrs) # type: SasviewModelType 155 return ConstructedModel 156 157 144 158 def _make_standard_model(name): 145 159 # type: (str) -> SasviewModelType … … 153 167 kernel_module = generate.load_kernel_module(name) 154 168 model_info = modelinfo.make_model_info(kernel_module) 155 return _make_model_from_info(model_info)156 157 169 return make_model_from_info(model_info) 170 171 158 172 def _register_old_models(): 159 173 # type: () -> None … … 187 201 model_info = product.make_product_info(form_factor._model_info, 188 202 structure_factor._model_info) 189 ConstructedModel = _make_model_from_info(model_info)203 ConstructedModel = make_model_from_info(model_info) 190 204 return ConstructedModel() 191 205 192 def _make_model_from_info(model_info):193 # type: (ModelInfo) -> SasviewModelType194 """195 Convert *model_info* into a SasView model wrapper.196 """197 def __init__(self, multiplicity=None):198 SasviewModel.__init__(self, multiplicity=multiplicity)199 attrs = _generate_model_attributes(model_info)200 attrs['__init__'] = __init__201 attrs['filename'] = model_info.filename202 ConstructedModel = type(model_info.name, (SasviewModel,), attrs) # type: SasviewModelType203 return ConstructedModel204 206 205 207 def _generate_model_attributes(model_info): … … 603 605 if hasattr(self._model_info, "composition") \ 604 606 and self._model_info.composition is not None: 605 p_model = _make_model_from_info(self._model_info.composition[1][0])()606 s_model = _make_model_from_info(self._model_info.composition[1][1])()607 p_model = make_model_from_info(self._model_info.composition[1][0])() 608 s_model = make_model_from_info(self._model_info.composition[1][1])() 607 609 return p_model, s_model 608 610
Note: See TracChangeset
for help on using the changeset viewer.