Changeset 689b7c4 in sasmodels for sasmodels/sasview_model.py
- Timestamp:
- Oct 10, 2016 2:51:17 PM (8 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:
- 234c532
- Parents:
- 9f37726 (diff), 20a70bc (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:
- wpotrzebowski <Wojciech.Potrzebowski@…> (10/10/16 14:51:07)
- git-committer:
- wpotrzebowski <Wojciech.Potrzebowski@…> (10/10/16 14:51:17)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/sasview_model.py
r9f37726 r689b7c4 123 123 if model.name == "": 124 124 model.name = splitext(basename(path))[0] 125 if not hasattr(model, 'filename'): 126 model.filename = kernel_module.__file__ 125 127 except AttributeError: 126 128 model_info = modelinfo.make_model_info(kernel_module) 127 129 model = _make_model_from_info(model_info) 128 130 129 # If we are trying to load a model that already exists, 130 # append a version number to its name. 131 # Note that models appear to be periodically reloaded 132 # by SasView and keeping track of whether we are reloading 133 # a model or loading it for the first time is tricky. 134 # For now, just allow one custom model of a given name. 135 if model.name in MODELS: 136 model.name = "%s_v2" % model.name 131 # If a model name already exists and we are loading a different model, 132 # use the model file name as the model name. 133 if model.name in MODELS and not model.filename == MODELS[model.name].filename: 134 _previous_name = model.name 135 model.name = model.id 136 137 # If the new model name is still in the model list (for instance, 138 # if we put a cylinder.py in our plug-in directory), then append 139 # an identifier. 140 if model.name in MODELS and not model.filename == MODELS[model.name].filename: 141 model.name = model.id + '_user' 142 logging.info("Model %s already exists: using %s [%s]", _previous_name, model.name, model.filename) 137 143 138 144 MODELS[model.name] = model … … 163 169 attrs = _generate_model_attributes(model_info) 164 170 attrs['__init__'] = __init__ 171 attrs['filename'] = model_info.filename 165 172 ConstructedModel = type(model_info.name, (SasviewModel,), attrs) # type: SasviewModelType 166 173 return ConstructedModel … … 320 327 else: 321 328 hidden = set() 329 if self._model_info.structure_factor: 330 hidden.add('scale') 331 hidden.add('background') 332 self._model_info.parameters.defaults['background'] = 0. 322 333 323 334 self._persistency_dict = {} … … 665 676 return [self.multiplicity], [1.0] 666 677 else: 667 return [np.NaN], [1.0] 678 # For hidden parameters use the default value. 679 value = self._model_info.parameters.defaults.get(par.name, np.NaN) 680 return [value], [1.0] 668 681 elif par.polydisperse: 669 682 dis = self.dispersion[par.name] … … 686 699 cylinder = Cylinder() 687 700 return cylinder.evalDistribution([0.1, 0.1]) 701 702 def test_structure_factor(): 703 # type: () -> float 704 """ 705 Test that a sasview model (cylinder) can be run. 706 """ 707 Model = _make_standard_model('hardsphere') 708 model = Model() 709 value = model.evalDistribution([0.1, 0.1]) 710 if np.isnan(value): 711 raise ValueError("hardsphere returns null") 688 712 689 713 def test_rpa():
Note: See TracChangeset
for help on using the changeset viewer.