Changeset 92d38285 in sasmodels
- Timestamp:
- Jun 22, 2016 12:13:32 PM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- b3a85cd
- Parents:
- f5dde3f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/sasview_model.py
rf36c1b7 r92d38285 5 5 create a sasview model class to run that kernel as follows:: 6 6 7 from sasmodels.sasview_model import make_class 8 from sasmodels.models import cylinder 9 CylinderModel = make_class(cylinder, dtype='single') 10 11 The model parameters for sasmodels are different from those in sasview. 12 When reloading previously saved models, the parameters should be converted 13 using :func:`sasmodels.convert.convert`. 7 from sasmodels.sasview_model import load_custom_model 8 CylinderModel = load_custom_model('sasmodels/models/cylinder.py') 14 9 """ 15 10 from __future__ import print_function … … 44 39 ) 45 40 41 MODELS = {} 42 def find_model(modelname): 43 # TODO: used by sum/product model to load an existing model 44 # TODO: doesn't handle custom models properly 45 if modelname.endswith('.py'): 46 return load_custom_model(modelname) 47 elif modelname in MODELS: 48 return MODELS[modelname] 49 else: 50 raise ValueError("unknown model %r"%modelname) 51 46 52 def load_standard_models(): 47 53 """ … … 54 60 for name in core.list_models(): 55 61 try: 56 models.append(_make_standard_model(name)) 57 except: 62 MODELS[name] = _make_standard_model(name) 63 models.append(MODELS[name]) 64 except Exception: 58 65 logging.error(traceback.format_exc()) 59 66 return models … … 64 71 Load a custom model given the model path. 65 72 """ 73 #print("load custom model", path) 66 74 kernel_module = custom.load_custom_kernel_module(path) 67 model_info = generate.make_model_info(kernel_module) 68 return _make_model_from_info(model_info) 75 try: 76 model = kernel_module.Model 77 except AttributeError: 78 model_info = generate.make_model_info(kernel_module) 79 model = _make_model_from_info(model_info) 80 MODELS[model.name] = model 81 return model 69 82 70 83
Note: See TracChangeset
for help on using the changeset viewer.