LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
|
Public Member Functions | |
def | __init__ |
def | rename |
def | validate |
def | freeze |
def | save |
def | toDict |
def | __get__ |
def | __set__ |
def | __delete__ |
Public Attributes | |
dtype | |
doc | |
default | |
check | |
optional | |
source | |
Static Public Attributes | |
tuple | supportedTypes = (str, bool, float, int, complex) |
Private Member Functions | |
def | _setup |
def | _validateValue |
def | _compare |
Private Attributes | |
__doc__ | |
A field in a a Config. Instances of Field should be class attributes of Config subclasses: Field only supports basic data types (int, float, complex, bool, str) class Example(Config): myInt = Field(int, "an integer field!", default=0)
def lsst.pex.config.config.Field.__init__ | ( | self, | |
doc, | |||
dtype, | |||
default = None , |
|||
check = None , |
|||
optional = False |
|||
) |
Initialize a Field. dtype ------ Data type for the field. doc -------- Documentation for the field. default ---- A default value for the field. check ------ A callable to be called with the field value that returns False if the value is invalid. More complex inter-field validation can be written as part of Config validate() method; this will be ignored if set to None. optional --- When False, Config validate() will fail if value is None
Definition at line 147 of file config.py.
def lsst.pex.config.config.Field.__delete__ | ( | self, | |
instance, | |||
at = None , |
|||
label = 'deletion' |
|||
) |
def lsst.pex.config.config.Field.__get__ | ( | self, | |
instance, | |||
owner = None , |
|||
at = None , |
|||
label = "default" |
|||
) |
Define how attribute access should occur on the Config instance This is invoked by the owning config object and should not be called directly When the field attribute is accessed on a Config class object, it returns the field object itself in order to allow inspection of Config classes. When the field attribute is access on a config instance, the actual value described by the field (and held by the Config instance) is returned.
Definition at line 261 of file config.py.
def lsst.pex.config.config.Field.__set__ | ( | self, | |
instance, | |||
value, | |||
at = None , |
|||
label = 'assignment' |
|||
) |
Describe how attribute setting should occur on the config instance. This is invoked by the owning config object and should not be called directly Derived Field classes may need to override the behavior. When overriding __set__, Field authors should follow the following rules: * Do not allow modification of frozen configs * Validate the new value *BEFORE* modifying the field. Except if the new value is None. None is special and no attempt should be made to validate it until Config.validate is called. * Do not modify the Config instance to contain invalid values. * If the field is modified, update the history of the field to reflect the changes In order to decrease the need to implement this method in derived Field types, value validation is performed in the method _validateValue. If only the validation step differs in the derived Field, it is simpler to implement _validateValue than to re-implement __set__. More complicated behavior, however, may require a reimplementation.
Definition at line 280 of file config.py.
|
private |
Helper function for Config.compare; used to compare two fields for equality. Must be overridden by more complex field types. @param[in] instance1 LHS Config instance to compare. @param[in] instance2 RHS Config instance to compare. @param[in] shortcut If True, return as soon as an inequality is found. @param[in] rtol Relative tolerance for floating point comparisons. @param[in] atol Absolute tolerance for floating point comparisons. @param[in] output If not None, a callable that takes a string, used (possibly repeatedly) to report inequalities. Floating point comparisons are performed by numpy.allclose; refer to that for details.
Definition at line 328 of file config.py.
|
private |
|
private |
def lsst.pex.config.config.Field.freeze | ( | self, | |
instance | |||
) |
def lsst.pex.config.config.Field.rename | ( | self, | |
instance | |||
) |
Rename an instance of this field, not the field itself. This is invoked by the owning config object and should not be called directly Only useful for fields which hold sub-configs. Fields which hold subconfigs should rename each sub-config with the full field name as generated by _joinNamePath
Definition at line 178 of file config.py.
def lsst.pex.config.config.Field.save | ( | self, | |
outfile, | |||
instance | |||
) |
def lsst.pex.config.config.Field.toDict | ( | self, | |
instance | |||
) |
Convert the field value so that it can be set as the value of an item in a dict. This is invoked by the owning config object and should not be called directly Simple values are passed through. Complex data structures must be manipulated. For example, a field holding a sub-config should, instead of the subconfig object, return a dict where the keys are the field names in the subconfig, and the values are the field values in the subconfig.
Definition at line 246 of file config.py.
def lsst.pex.config.config.Field.validate | ( | self, | |
instance | |||
) |
|
static |