Changeset b8e5e21 in sasmodels for sasmodels/generate.py


Ignore:
Timestamp:
Mar 16, 2016 8:22:29 AM (8 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.