Changeset b8e5e21 in sasmodels
- Timestamp:
- Mar 16, 2016 8:22:29 AM (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:
- 28da77d
- Parents:
- 667a6f2
- Location:
- sasmodels
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare_many.py
r17bbadd rb8e5e21 109 109 110 110 if is_2d: 111 partype = model_info['partype'] 112 if not partype['orientation'] and not partype['magnetic']: 111 if not model_info['has_2d']: 113 112 print(',"1-D only"') 114 113 return -
sasmodels/core.py
r17bbadd rb8e5e21 34 34 return available_models 35 35 36 def isstr(s): 37 """ 38 Return True if *s* is a string-like object. 39 """ 40 try: s + '' 41 except: return False 42 return True 43 44 def load_model(model_name, **kw): 45 """ 46 Load model info and build model. 47 """ 48 return build_model(load_model_info(model_name), **kw) 36 49 37 50 def load_model_info(model_name): … … 46 59 return generate.make_model_info(kernel_module) 47 60 48 49 def precompile_dll(model_name, dtype="double"):50 """51 Precompile the dll for a model.52 53 Returns the path to the compiled model, or None if the model is a pure54 python model.55 56 This can be used when build the windows distribution of sasmodels57 (which may be missing the OpenCL driver and the dll compiler), or58 otherwise sharing models with windows users who do not have a compiler.59 60 See :func:`sasmodels.kerneldll.make_dll` for details on controlling the61 dll path and the allowed floating point precision.62 """63 model_info = load_model_info(model_name)64 source = generate.make_source(model_info)65 return kerneldll.make_dll(source, model_info, dtype=dtype) if source else None66 67 68 def isstr(s):69 """70 Return True if *s* is a string-like object.71 """72 try: s + ''73 except: return False74 return True75 61 76 62 def build_model(model_info, dtype=None, platform="ocl"): … … 114 100 else: 115 101 return kernelcl.GpuModel(source, model_info, dtype) 102 103 def precompile_dll(model_name, dtype="double"): 104 """ 105 Precompile the dll for a model. 106 107 Returns the path to the compiled model, or None if the model is a pure 108 python model. 109 110 This can be used when build the windows distribution of sasmodels 111 (which may be missing the OpenCL driver and the dll compiler), or 112 otherwise sharing models with windows users who do not have a compiler. 113 114 See :func:`sasmodels.kerneldll.make_dll` for details on controlling the 115 dll path and the allowed floating point precision. 116 """ 117 model_info = load_model_info(model_name) 118 source = generate.make_source(model_info) 119 return kerneldll.make_dll(source, model_info, dtype=dtype) if source else None 120 116 121 117 122 def make_kernel(model, q_vectors): -
sasmodels/generate.py
r17bbadd rb8e5e21 235 235 COMMON_PARAMETERS = [ 236 236 ["scale", "", 1, [0, np.inf], "", "Source intensity"], 237 ["background", "1/cm", 0, [0, np.inf], "", "Source background"],237 ["background", "1/cm", 1e-3, [0, np.inf], "", "Source background"], 238 238 ] 239 239 … … 629 629 """ 630 630 # Fill in the derived attributes 631 partype = categorize_parameters(model_info['parameters']) 631 632 model_info['limits'] = dict((p[0], p[3]) for p in model_info['parameters']) 632 model_info['partype'] = categorize_parameters(model_info['parameters'])633 model_info['partype'] = partype 633 634 model_info['defaults'] = dict((p[0], p[2]) for p in model_info['parameters']) 634 635 if model_info.get('demo', None) is None: 635 636 model_info['demo'] = model_info['defaults'] 637 model_info['has_2d'] = partype['orientation'] or partype['magnetic'] 636 638 637 639 def make_model_info(kernel_module): … … 655 657 * *parameters* is the model parameter table 656 658 * *single* is True if the model allows single precision 659 * *structure_factor* is True if the model is useable in a product 660 * *variant_info* contains the information required to select between 661 model variants (e.g., the list of cases) or is None if there are no 662 model variants 657 663 * *defaults* is the *{parameter: value}* table built from the parameter 658 664 description table. … … 678 684 """ 679 685 # TODO: maybe turn model_info into a class ModelDefinition 680 #print(kernelfile)681 category = getattr(kernel_module, 'category', None)682 686 parameters = COMMON_PARAMETERS + kernel_module.parameters 683 # Default the demo parameters to the starting values for the individual684 # parameters if an explicit demo parameter set has not been specified.685 demo_parameters = getattr(kernel_module, 'demo', None)686 687 filename = abspath(kernel_module.__file__) 687 688 kernel_id = splitext(basename(filename))[0] 688 689 name = getattr(kernel_module, 'name', None) 689 single = getattr(kernel_module, 'single', True)690 690 if name is None: 691 691 name = " ".join(w.capitalize() for w in kernel_id.split('_')) … … 696 696 title=kernel_module.title, 697 697 description=kernel_module.description, 698 docs=kernel_module.__doc__,699 category=category,700 698 parameters=parameters, 701 699 composition=None, 702 single=single, 703 demo=demo_parameters, 700 docs=kernel_module.__doc__, 701 category=getattr(kernel_module, 'category', None), 702 single=getattr(kernel_module, 'single', True), 703 structure_factor=getattr(kernel_module, 'structure_factor', False), 704 variant_info=getattr(kernel_module, 'invariant_info', None), 705 demo=getattr(kernel_module, 'demo', None), 704 706 source=getattr(kernel_module, 'source', []), 705 707 oldname=getattr(kernel_module, 'oldname', None), … … 708 710 ) 709 711 process_parameters(model_info) 710 # Fill in a ttributes which default to None712 # Fill in available functions 711 713 model_info.update((k, getattr(kernel_module, k, None)) 712 714 for k in ('ER', 'VR', 'form_volume', 'Iq', 'Iqxy'))
Note: See TracChangeset
for help on using the changeset viewer.