Changeset b8e5e21 in sasmodels


Ignore:
Timestamp:
Mar 16, 2016 8:22:29 AM (9 years ago)
Author:
Paul Kienzle <pkienzle@…>
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
Message:

had structure_factor, has_2d and variants to info

Location:
sasmodels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare_many.py

    r17bbadd rb8e5e21  
    109109 
    110110    if is_2d: 
    111         partype = model_info['partype'] 
    112         if not partype['orientation'] and not partype['magnetic']: 
     111        if not model_info['has_2d']: 
    113112            print(',"1-D only"') 
    114113            return 
  • sasmodels/core.py

    r17bbadd rb8e5e21  
    3434    return available_models 
    3535 
     36def 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 
     44def load_model(model_name, **kw): 
     45    """ 
     46    Load model info and build model. 
     47    """ 
     48    return build_model(load_model_info(model_name), **kw) 
    3649 
    3750def load_model_info(model_name): 
     
    4659    return generate.make_model_info(kernel_module) 
    4760 
    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 pure 
    54     python model. 
    55  
    56     This can be used when build the windows distribution of sasmodels 
    57     (which may be missing the OpenCL driver and the dll compiler), or 
    58     otherwise sharing models with windows users who do not have a compiler. 
    59  
    60     See :func:`sasmodels.kerneldll.make_dll` for details on controlling the 
    61     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 None 
    66  
    67  
    68 def isstr(s): 
    69     """ 
    70     Return True if *s* is a string-like object. 
    71     """ 
    72     try: s + '' 
    73     except: return False 
    74     return True 
    7561 
    7662def build_model(model_info, dtype=None, platform="ocl"): 
     
    114100    else: 
    115101        return kernelcl.GpuModel(source, model_info, dtype) 
     102 
     103def 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 
    116121 
    117122def make_kernel(model, q_vectors): 
  • sasmodels/generate.py

    r17bbadd rb8e5e21  
    235235COMMON_PARAMETERS = [ 
    236236    ["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"], 
    238238    ] 
    239239 
     
    629629    """ 
    630630    # Fill in the derived attributes 
     631    partype = categorize_parameters(model_info['parameters']) 
    631632    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 
    633634    model_info['defaults'] = dict((p[0], p[2]) for p in model_info['parameters']) 
    634635    if model_info.get('demo', None) is None: 
    635636        model_info['demo'] = model_info['defaults'] 
     637    model_info['has_2d'] = partype['orientation'] or partype['magnetic'] 
    636638 
    637639def make_model_info(kernel_module): 
     
    655657    * *parameters* is the model parameter table 
    656658    * *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 
    657663    * *defaults* is the *{parameter: value}* table built from the parameter 
    658664      description table. 
     
    678684    """ 
    679685    # TODO: maybe turn model_info into a class ModelDefinition 
    680     #print(kernelfile) 
    681     category = getattr(kernel_module, 'category', None) 
    682686    parameters = COMMON_PARAMETERS + kernel_module.parameters 
    683     # Default the demo parameters to the starting values for the individual 
    684     # parameters if an explicit demo parameter set has not been specified. 
    685     demo_parameters = getattr(kernel_module, 'demo', None) 
    686687    filename = abspath(kernel_module.__file__) 
    687688    kernel_id = splitext(basename(filename))[0] 
    688689    name = getattr(kernel_module, 'name', None) 
    689     single = getattr(kernel_module, 'single', True) 
    690690    if name is None: 
    691691        name = " ".join(w.capitalize() for w in kernel_id.split('_')) 
     
    696696        title=kernel_module.title, 
    697697        description=kernel_module.description, 
    698         docs=kernel_module.__doc__, 
    699         category=category, 
    700698        parameters=parameters, 
    701699        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), 
    704706        source=getattr(kernel_module, 'source', []), 
    705707        oldname=getattr(kernel_module, 'oldname', None), 
     
    708710        ) 
    709711    process_parameters(model_info) 
    710     # Fill in attributes which default to None 
     712    # Fill in available functions 
    711713    model_info.update((k, getattr(kernel_module, k, None)) 
    712714                      for k in ('ER', 'VR', 'form_volume', 'Iq', 'Iqxy')) 
Note: See TracChangeset for help on using the changeset viewer.