Changeset 7edce22 in sasmodels
- Timestamp:
- Apr 8, 2016 5:39:28 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:
- 0d99a6a
- Parents:
- a86f6c0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/modelinfo.py
ra86f6c0 r7edce22 22 22 TestCondition = Tuple[ParameterSetUser, TestInput, TestValue] 23 23 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" 24 MAX_PD = 4 #: Maximum number of simultaneously polydisperse parameters 25 33 26 # assumptions about common parameters exist throughout the code, such as: 34 27 # (1) kernel functions Iq, Iqxy, form_volume, ... don't see them … … 40 33 # Note that scale and background cannot be coordinated parameters whose value 41 34 # depends on the some polydisperse parameter with the current implementation 35 COMMON_PARAMETERS = [ 36 ["scale", "", 1, [0, np.inf], "", "Source intensity"], 37 ["background", "1/cm", 1e-3, [0, np.inf], "", "Source background"], 38 ] 39 assert (len(COMMON_PARAMETERS) == 2 40 and COMMON_PARAMETERS[0][0]=="scale" 41 and COMMON_PARAMETERS[1][0]=="background"), "don't change common parameters" 42 42 43 43 44 44 def make_parameter_table(pars): 45 45 # 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 """ 46 52 processed = [] 47 53 for p in pars: … … 55 61 def parse_parameter(name, units='', default=np.NaN, 56 62 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 """ 57 69 # type: (str, str, float, LimitsOrChoice, str, str) -> Parameter 58 70 # Parameter is a user facing class. Do robust type checking. … … 577 589 return result 578 590 579 580 581 591 def isstr(x): 582 592 # type: (Any) -> bool 593 """ 594 Return True if the object is a string. 595 """ 583 596 # TODO: 2-3 compatible tests for str, including unicode strings 584 597 return isinstance(x, str) 585 598 586 599 def 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 """ 587 609 info = ModelInfo() 588 610 #print("make parameter table", kernel_module.parameters) … … 662 684 *model_info* blocks for the composition objects. This allows us to 663 685 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. 664 689 """ 665 690 id = None # type: str
Note: See TracChangeset
for help on using the changeset viewer.