lsst.pex.config
13.0-2-g483026c+3
|
Public Member Functions | |
def | __iter__ |
Iterate over fields. More... | |
def | keys |
Return the list of field names. More... | |
def | values |
Return the list of field values. More... | |
def | items |
Return the list of (field name, field value) pairs. More... | |
def | iteritems |
Iterate over (field name, field value) pairs. More... | |
def | itervalues |
Iterate over field values. More... | |
def | iterkeys |
Iterate over field names. More... | |
def | __contains__ |
Return True if the specified field exists in this config. More... | |
def | __new__ |
Allocate a new Config object. More... | |
def | __reduce__ |
def | setDefaults |
def | update |
Update values specified by the keyword arguments. More... | |
def | load |
Modify this config in place by executing the Python code in the named file. More... | |
def | loadFromStream |
Modify this config in place by executing the python code in the provided stream. More... | |
def | save |
Save a python script to the named file, which, when loaded, reproduces this Config. More... | |
def | saveToStream |
Save a python script to a stream, which, when loaded, reproduces this Config. More... | |
def | freeze |
Make this Config and all sub-configs read-only. More... | |
def | toDict |
Return a dict of field name: value. More... | |
def | validate |
Validate the Config; raise an exception if invalid. More... | |
def | formatHistory |
Format the specified config field's history to a more human-readable format. More... | |
def | __setattr__ |
Regulate which attributes can be set. More... | |
def | __delattr__ |
def | __eq__ |
def | __ne__ |
def | __str__ |
def | __repr__ |
def | compare |
Compare two Configs for equality; return True if equal. More... | |
![]() | |
def | __init__ |
def | __setattr__ |
Properties | |
history = property(lambda x: x._history) | |
Base class for control objects. A Config object will usually have several Field instances as class attributes; these are used to define most of the base class behavior. Simple derived class should be able to be defined simply by setting those attributes. Config also emulates a dict of field name: field value
def lsst.pex.config.config.Config.__contains__ | ( | self, | |
name | |||
) |
def lsst.pex.config.config.Config.__delattr__ | ( | self, | |
attr, | |||
at = None , |
|||
label = "deletion" |
|||
) |
def lsst.pex.config.config.Config.__iter__ | ( | self | ) |
def lsst.pex.config.config.Config.__new__ | ( | cls, | |
args, | |||
kw | |||
) |
Allocate a new Config object.
In order to ensure that all Config object are always in a proper state when handed to users or to derived Config classes, some attributes are handled at allocation time rather than at initialization
This ensures that even if a derived Config class implements init, the author does not need to be concerned about when or even if he should call the base Config.__init__
def lsst.pex.config.config.Config.__reduce__ | ( | self | ) |
def lsst.pex.config.config.Config.__setattr__ | ( | self, | |
attr, | |||
value, | |||
at = None , |
|||
label = "assignment" |
|||
) |
Regulate which attributes can be set.
Unlike normal python objects, Config objects are locked such that no additional attributes nor properties may be added to them dynamically.
Although this is not the standard Python behavior, it helps to protect users from accidentally mispelling a field name, or trying to set a non-existent field.
def lsst.pex.config.config.Config.compare | ( | self, | |
other, | |||
shortcut = True , |
|||
rtol = 1E-8 , |
|||
atol = 1E-8 , |
|||
output = None |
|||
) |
Compare two Configs for equality; return True if equal.
If the Configs contain RegistryFields or ConfigChoiceFields, unselected Configs will not be compared.
[in] | other | Config object to compare with self. |
[in] | shortcut | If True, return as soon as an inequality is found. |
[in] | rtol | Relative tolerance for floating point comparisons. |
[in] | atol | Absolute tolerance for floating point comparisons. |
[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.
def lsst.pex.config.config.Config.formatHistory | ( | self, | |
name, | |||
kwargs | |||
) |
Format the specified config field's history to a more human-readable format.
[in] | name | name of field whose history is wanted |
[in] | kwargs | keyword arguments for lsst.pex.config.history.format |
def lsst.pex.config.config.Config.freeze | ( | self | ) |
def lsst.pex.config.config.Config.items | ( | self | ) |
def lsst.pex.config.config.Config.iteritems | ( | self | ) |
def lsst.pex.config.config.Config.iterkeys | ( | self | ) |
def lsst.pex.config.config.Config.itervalues | ( | self | ) |
def lsst.pex.config.config.Config.keys | ( | self | ) |
def lsst.pex.config.config.Config.load | ( | self, | |
filename, | |||
root = "config" |
|||
) |
Modify this config in place by executing the Python code in the named file.
[in] | filename | name of file containing config override code |
[in] | root | name of variable in file that refers to the config being overridden |
For example: if the value of root is "config" and the file contains this text: "config.myField = 5" then this config's field "myField" is set to 5.
def lsst.pex.config.config.Config.loadFromStream | ( | self, | |
stream, | |||
root = "config" , |
|||
filename = None |
|||
) |
Modify this config in place by executing the python code in the provided stream.
[in] | stream | open file object, string or compiled string containing config override code |
[in] | root | name of variable in stream that refers to the config being overridden |
[in] | filename | name of config override file, or None if unknown or contained in the stream; used for error reporting |
For example: if the value of root is "config" and the stream contains this text: "config.myField = 5" then this config's field "myField" is set to 5.
def lsst.pex.config.config.Config.save | ( | self, | |
filename, | |||
root = "config" |
|||
) |
def lsst.pex.config.config.Config.saveToStream | ( | self, | |
outfile, | |||
root = "config" |
|||
) |
Save a python script to a stream, which, when loaded, reproduces this Config.
outfile | [inout] open file object to which to write the config. Accepts strings not bytes. |
root | [in] name to use for the root config variable; the same value must be used when loading |
def lsst.pex.config.config.Config.setDefaults | ( | self | ) |
def lsst.pex.config.config.Config.toDict | ( | self | ) |
Return a dict of field name: value.
Correct behavior is dependent on proper implementation of Field.toDict. If implementing a new Field type, you may need to implement your own toDict method.
def lsst.pex.config.config.Config.update | ( | self, | |
kw | |||
) |
Update values specified by the keyword arguments.
def lsst.pex.config.config.Config.validate | ( | self | ) |
Validate the Config; raise an exception if invalid.
The base class implementation performs type checks on all fields by calling Field.validate().
Complex single-field validation can be defined by deriving new Field types. As syntactic sugar, some derived Field types are defined in this module which handle recursing into sub-configs (ConfigField, ConfigChoiceField)
Inter-field relationships should only be checked in derived Config classes after calling this method, and base validation is complete
def lsst.pex.config.config.Config.values | ( | self | ) |
|
static |