Changeset c499331 in sasmodels
- Timestamp:
- Mar 25, 2016 5:45:02 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:
- d19962c
- Parents:
- 5ff1b03
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r380e8c9 rc499331 307 307 """ 308 308 lines = [] 309 for p in model_info['parameters'].type['2d' if is2d else '1d']: 310 fields = dict( 311 value=pars.get(p.name, p.default), 312 pd=pars.get(p.name+"_pd", 0.), 313 n=int(pars.get(p.name+"_pd_n", 0)), 314 nsigma=pars.get(p.name+"_pd_nsgima", 3.), 315 type=pars.get(p.name+"_pd_type", 'gaussian')) 316 lines.append(_format_par(p.name, **fields)) 309 parameters = model_info['parameters'] 310 for p in parameters.type['2d' if is2d else '1d']: 311 if p.length > 1: 312 for k in range(p.length): 313 ext = "[%d]"%k 314 fields = dict( 315 value=pars.get(p.id+ext, p.default), 316 pd=pars.get(p.id+"_pd"+ext, 0.), 317 n=int(pars.get(p.id+"_pd_n"+ext, 0)), 318 nsigma=pars.get(p.id+"_pd_nsgima"+ext, 3.), 319 type=pars.get(p.id+"_pd_type"+ext, 'gaussian')) 320 lines.append(_format_par(p.id+ext, **fields)) 321 else: 322 fields = dict( 323 value=pars.get(p.id, p.default), 324 pd=pars.get(p.id+"_pd", 0.), 325 n=int(pars.get(p.id+"_pd_n", 0)), 326 nsigma=pars.get(p.id+"_pd_nsgima", 3.), 327 type=pars.get(p.id+"_pd_type", 'gaussian')) 328 lines.append(_format_par(p.name, **fields)) 317 329 return "\n".join(lines) 318 330 … … 655 667 """ 656 668 # Get the default values for the parameters 657 pars = dict((p.name, p.default) for p in model_info['parameters']) 658 659 # Fill in default values for the polydispersity parameters 669 pars = {} 660 670 for p in model_info['parameters']: 661 if p.type in ('volume', 'orientation'): 662 pars[p.name+'_pd'] = 0.0 663 pars[p.name+'_pd_n'] = 0 664 pars[p.name+'_pd_nsigma'] = 3.0 665 pars[p.name+'_pd_type'] = "gaussian" 671 parts = [('', p.default)] 672 if p.polydisperse: 673 parts.append(('_pd', 0.0)) 674 parts.append(('_pd_n', 0)) 675 parts.append(('_pd_nsigma', 3.0)) 676 parts.append(('_pd_type', "gaussian")) 677 for ext, val in parts: 678 if p.length > 1: 679 dict(("%s%s[%d]"%(p.id,ext,k), val) for k in range(p.length)) 680 else: 681 pars[p.id+ext] = val 666 682 667 683 # Plug in values given in demo … … 693 709 name = args[0] 694 710 try: 695 model_info = core.load_model_info(name) 711 if name.endswith('.py'): 712 model_info = core.load_model_info_from_path(name) 713 else: 714 model_info = core.load_model_info(name) 696 715 except ImportError, exc: 697 716 print(str(exc)) … … 768 787 769 788 if len(engines) == 0: 770 engines.extend(['single', ' sasview'])789 engines.extend(['single', 'double']) 771 790 elif len(engines) == 1: 772 if engines[0][0] != ' sasview':773 engines.append(' sasview')791 if engines[0][0] != 'double': 792 engines.append('double') 774 793 else: 775 794 engines.append('single') -
sasmodels/core.py
r5ff1b03 rc499331 29 29 ] 30 30 31 try: 32 # Python 3.5 and up 33 from importlib.util import spec_from_file_location, module_from_spec 34 def load_module(fullname, path): 35 spec = spec_from_file_location(fullname, path) 36 module = module_from_spec(spec) 37 spec.loader.exec_module(module) 38 return module 39 except ImportError: 40 # CRUFT: python 2 41 import imp 42 def load_module(fullname, path): 43 module = imp.load_source(fullname, path) 44 return module 45 31 46 def list_models(): 32 47 """ … … 50 65 Load model info and build model. 51 66 """ 52 return build_model(load_model_info(model_name), **kw) 67 if model_name.endswith('.py'): 68 model_info = load_model_info_from_path(model_name) 69 else: 70 model_info = load_model_info(model_name) 71 return build_model(model_info, **kw) 53 72 54 73 def load_model_info_from_path(path): … … 63 82 # though it doesn't actually exist. imp.load_source doesn't seem 64 83 # to care. 65 kernel_module = imp.load_source('sasmodels.custom.'+name, path) 84 import sasmodels.custom 85 kernel_module = load_module('sasmodels.custom.'+name, path) 66 86 67 87 # Now that we have the module, we can load it as usual -
sasmodels/modelinfo.py
r60eab2a rc499331 236 236 if int(low) != low or int(high) != high or low<0 or high>20: 237 237 raise ValueError("expected limits on %s to be within [0, 20]"%ref.name) 238 p.length = low238 p.length = high 239 239 240 240 def _set_defaults(self):
Note: See TracChangeset
for help on using the changeset viewer.