Changeset 7edce22 in sasmodels


Ignore:
Timestamp:
Apr 8, 2016 5:39:28 PM (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:
0d99a6a
Parents:
a86f6c0
Message:

doc strings for modelinfo

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/modelinfo.py

    ra86f6c0 r7edce22  
    2222    TestCondition = Tuple[ParameterSetUser, TestInput, TestValue] 
    2323 
    24 MAX_PD = 4 
    25  
    26 COMMON_PARAMETERS = [ 
    27     ["scale", "", 1, [0, np.inf], "", "Source intensity"], 
    28     ["background", "1/cm", 1e-3, [0, np.inf], "", "Source background"], 
    29 ] 
    30 assert (len(COMMON_PARAMETERS) == 2 
    31         and COMMON_PARAMETERS[0][0]=="scale" 
    32         and COMMON_PARAMETERS[1][0]=="background"), "don't change common parameters" 
     24MAX_PD = 4 #: Maximum number of simultaneously polydisperse parameters 
     25 
    3326# assumptions about common parameters exist throughout the code, such as: 
    3427# (1) kernel functions Iq, Iqxy, form_volume, ... don't see them 
     
    4033# Note that scale and background cannot be coordinated parameters whose value 
    4134# depends on the some polydisperse parameter with the current implementation 
     35COMMON_PARAMETERS = [ 
     36    ["scale", "", 1, [0, np.inf], "", "Source intensity"], 
     37    ["background", "1/cm", 1e-3, [0, np.inf], "", "Source background"], 
     38] 
     39assert (len(COMMON_PARAMETERS) == 2 
     40        and COMMON_PARAMETERS[0][0]=="scale" 
     41        and COMMON_PARAMETERS[1][0]=="background"), "don't change common parameters" 
    4242 
    4343 
    4444def make_parameter_table(pars): 
    4545    # type: (List[ParameterDefinition) -> ParameterTable 
     46    """ 
     47    Construct a parameter table from a list of parameter definitions. 
     48 
     49    This is used by the module processor to convert the parameter block into 
     50    the parameter table seen in the :class:`ModelInfo` for the module. 
     51    """ 
    4652    processed = [] 
    4753    for p in pars: 
     
    5561def parse_parameter(name, units='', default=np.NaN, 
    5662                    limits=(-np.inf, np.inf), ptype='', description=''): 
     63    """ 
     64    Parse an individual parameter from the parameter definition block. 
     65 
     66    This does type and value checking on the definition, leading 
     67    to early failure in the model loading process and easier debugging. 
     68    """ 
    5769    # type: (str, str, float, LimitsOrChoice, str, str) -> Parameter 
    5870    # Parameter is a user facing class.  Do robust type checking. 
     
    577589        return result 
    578590 
    579  
    580  
    581591def isstr(x): 
    582592    # type: (Any) -> bool 
     593    """ 
     594    Return True if the object is a string. 
     595    """ 
    583596    # TODO: 2-3 compatible tests for str, including unicode strings 
    584597    return isinstance(x, str) 
    585598 
    586599def make_model_info(kernel_module): 
     600    # type: (module) -> ModelInfo 
     601    """ 
     602    Extract the model definition from the loaded kernel module. 
     603 
     604    Fill in default values for parts of the module that are not provided. 
     605 
     606    Note: vectorized Iq and Iqxy functions will be created for python 
     607    models when the model is first called, not when the model is loaded. 
     608    """ 
    587609    info = ModelInfo() 
    588610    #print("make parameter table", kernel_module.parameters) 
     
    662684      *model_info* blocks for the composition objects.  This allows us to 
    663685      build complete product and mixture models from just the info. 
     686 
     687    The structure should be mostly static, other than the delayed definition 
     688    of *Iq* and *Iqxy* if they need to be defined. 
    664689    """ 
    665690    id = None               # type: str 
Note: See TracChangeset for help on using the changeset viewer.