|
def | __iter__ (self) |
|
def | keys (self) |
|
def | values (self) |
|
def | items (self) |
|
def | iteritems (self) |
|
def | itervalues (self) |
|
def | iterkeys (self) |
|
def | __contains__ (self, name) |
| Return True if the specified field exists in this config. More...
|
|
def | __new__ (cls, args, kw) |
|
def | __reduce__ (self) |
|
def | setDefaults (self) |
|
def | update (self, kw) |
|
def | load (self, filename, root="config") |
|
def | loadFromStream (self, stream, root="config", filename=None) |
|
def | save (self, filename, root="config") |
|
def | saveToStream (self, outfile, root="config") |
|
def | freeze (self) |
|
def | toDict (self) |
|
def | names (self) |
|
def | validate (self) |
|
def | formatHistory (self, name, kwargs) |
|
def | __setattr__ (self, attr, value, at=None, label="assignment") |
|
def | __setattr__ (cls, name, value) |
|
def | __delattr__ (self, attr, at=None, label="deletion") |
|
def | __eq__ (self, other) |
|
def | __ne__ (self, other) |
|
def | __str__ (self) |
|
def | __repr__ (self) |
|
def | compare (self, other, shortcut=True, rtol=1E-8, atol=1E-8, output=None) |
|
|
| history = property(lambda x: x._history) |
|
Configuration for the forced transformed centroid algorithm.
Definition at line 557 of file plugins.py.
◆ __contains__()
def lsst.pex.config.config.Config.__contains__ |
( |
|
self, |
|
|
|
name |
|
) |
| |
|
inherited |
Return True if the specified field exists in this config.
- Parameters
-
[in] | name | field name to test for |
Definition at line 803 of file config.py.
803 def __contains__(self, name):
804 """!Return True if the specified field exists in this config 806 @param[in] name field name to test for 808 return self._storage.__contains__(name)
◆ __delattr__()
def lsst.pex.config.config.Config.__delattr__ |
( |
|
self, |
|
|
|
attr, |
|
|
|
at = None , |
|
|
|
label = "deletion" |
|
) |
| |
|
inherited |
Definition at line 1275 of file config.py.
1275 def __delattr__(self, attr, at=None, label="deletion"):
1276 if attr
in self._fields:
1279 self._fields[attr].__delete__(self, at=at, label=label)
1281 object.__delattr__(self, attr)
◆ __eq__()
def lsst.pex.config.config.Config.__eq__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
|
inherited |
Definition at line 1283 of file config.py.
1283 def __eq__(self, other):
1285 for name
in self._fields:
1286 thisValue = getattr(self, name)
1287 otherValue = getattr(other, name)
1288 if isinstance(thisValue, float)
and math.isnan(thisValue):
1289 if not math.isnan(otherValue):
1291 elif thisValue != otherValue:
◆ __iter__()
def lsst.pex.config.config.Config.__iter__ |
( |
|
self | ) |
|
|
inherited |
Iterate over fields.
Definition at line 708 of file config.py.
709 """Iterate over fields. 711 return self._fields.__iter__()
◆ __ne__()
def lsst.pex.config.config.Config.__ne__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
|
inherited |
Definition at line 1296 of file config.py.
1296 def __ne__(self, other):
1297 return not self.__eq__(other)
◆ __new__()
def lsst.pex.config.config.Config.__new__ |
( |
|
cls, |
|
|
|
args, |
|
|
|
kw |
|
) |
| |
|
inherited |
Allocate a new `lsst.pex.config.Config` object.
In order to ensure that all Config object are always in a proper state
when handed to users or to derived `~lsst.pex.config.Config` classes,
some attributes are handled at allocation time rather than at
initialization.
This ensures that even if a derived `~lsst.pex.config.Config` class
implements ``__init__``, its author does not need to be concerned about
when or even the base ``Config.__init__`` should be called.
Definition at line 810 of file config.py.
810 def __new__(cls, *args, **kw):
811 """Allocate a new `lsst.pex.config.Config` object. 813 In order to ensure that all Config object are always in a proper state 814 when handed to users or to derived `~lsst.pex.config.Config` classes, 815 some attributes are handled at allocation time rather than at 818 This ensures that even if a derived `~lsst.pex.config.Config` class 819 implements ``__init__``, its author does not need to be concerned about 820 when or even the base ``Config.__init__`` should be called. 822 name = kw.pop(
"__name",
None)
825 kw.pop(
"__label",
"default")
827 instance = object.__new__(cls)
828 instance._frozen =
False 829 instance._name = name
830 instance._storage = {}
831 instance._history = {}
832 instance._imports =
set()
834 for field
in instance._fields.values():
835 instance._history[field.name] = []
836 field.__set__(instance, field.default, at=at + [field.source], label=
"default")
838 instance.setDefaults()
840 instance.update(__at=at, **kw)
daf::base::PropertySet * set
◆ __reduce__()
def lsst.pex.config.config.Config.__reduce__ |
( |
|
self | ) |
|
|
inherited |
Reduction for pickling (function with arguments to reproduce).
We need to condense and reconstitute the `~lsst.pex.config.Config`,
since it may contain lambdas (as the ``check`` elements) that cannot
be pickled.
Definition at line 843 of file config.py.
843 def __reduce__(self):
844 """Reduction for pickling (function with arguments to reproduce). 846 We need to condense and reconstitute the `~lsst.pex.config.Config`, 847 since it may contain lambdas (as the ``check`` elements) that cannot 851 stream = io.StringIO()
852 self.saveToStream(stream)
853 return (unreduceConfig, (self.__class__, stream.getvalue().encode()))
◆ __repr__()
def lsst.pex.config.config.Config.__repr__ |
( |
|
self | ) |
|
|
inherited |
Definition at line 1302 of file config.py.
1305 ", ".join(
"%s=%r" % (k, v)
for k, v
in self.toDict().
items()
if v
is not None)
std::vector< SchemaItem< Flag > > * items
◆ __setattr__() [1/2]
def lsst.pex.config.config.ConfigMeta.__setattr__ |
( |
|
cls, |
|
|
|
name, |
|
|
|
value |
|
) |
| |
|
inherited |
Definition at line 130 of file config.py.
130 def __setattr__(cls, name, value):
131 if isinstance(value, Field):
133 cls._fields[name] = value
134 type.__setattr__(cls, name, value)
◆ __setattr__() [2/2]
def lsst.pex.config.config.Config.__setattr__ |
( |
|
self, |
|
|
|
attr, |
|
|
|
value, |
|
|
|
at = None , |
|
|
|
label = "assignment" |
|
) |
| |
|
inherited |
Set an attribute (such as a field's value).
Notes
-----
Unlike normal Python objects, `~lsst.pex.config.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.
Definition at line 1247 of file config.py.
1247 def __setattr__(self, attr, value, at=None, label="assignment"):
1248 """Set an attribute (such as a field's value). 1252 Unlike normal Python objects, `~lsst.pex.config.Config` objects are 1253 locked such that no additional attributes nor properties may be added 1254 to them dynamically. 1256 Although this is not the standard Python behavior, it helps to protect 1257 users from accidentally mispelling a field name, or trying to set a 1260 if attr
in self._fields:
1264 self._fields[attr].__set__(self, value, at=at, label=label)
1265 elif hasattr(getattr(self.__class__, attr,
None),
'__set__'):
1267 return object.__setattr__(self, attr, value)
1268 elif attr
in self.__dict__
or attr
in (
"_name",
"_history",
"_storage",
"_frozen",
"_imports"):
1270 self.__dict__[attr] = value
1273 raise AttributeError(
"%s has no attribute %s" % (_typeStr(self), attr))
◆ __str__()
def lsst.pex.config.config.Config.__str__ |
( |
|
self | ) |
|
|
inherited |
◆ compare()
def lsst.pex.config.config.Config.compare |
( |
|
self, |
|
|
|
other, |
|
|
|
shortcut = True , |
|
|
|
rtol = 1E-8 , |
|
|
|
atol = 1E-8 , |
|
|
|
output = None |
|
) |
| |
|
inherited |
Compare this configuration to another `~lsst.pex.config.Config` for
equality.
Parameters
----------
other : `lsst.pex.config.Config`
Other `~lsst.pex.config.Config` object to compare against this
config.
shortcut : `bool`, optional
If `True`, return as soon as an inequality is found. Default is
`True`.
rtol : `float`, optional
Relative tolerance for floating point comparisons.
atol : `float`, optional
Absolute tolerance for floating point comparisons.
output : callable, optional
A callable that takes a string, used (possibly repeatedly) to
report inequalities.
Returns
-------
isEqual : `bool`
`True` when the two `lsst.pex.config.Config` instances are equal.
`False` if there is an inequality.
See also
--------
lsst.pex.config.compareConfigs
Notes
-----
Unselected targets of `~lsst.pex.config.RegistryField` fields and
unselected choices of `~lsst.pex.config.ConfigChoiceField` fields
are not considered by this method.
Floating point comparisons are performed by `numpy.allclose`.
Definition at line 1308 of file config.py.
1308 def compare(self, other, shortcut=True, rtol=1E-8, atol=1E-8, output=None):
1309 """Compare this configuration to another `~lsst.pex.config.Config` for 1314 other : `lsst.pex.config.Config` 1315 Other `~lsst.pex.config.Config` object to compare against this 1317 shortcut : `bool`, optional 1318 If `True`, return as soon as an inequality is found. Default is 1320 rtol : `float`, optional 1321 Relative tolerance for floating point comparisons. 1322 atol : `float`, optional 1323 Absolute tolerance for floating point comparisons. 1324 output : callable, optional 1325 A callable that takes a string, used (possibly repeatedly) to 1326 report inequalities. 1331 `True` when the two `lsst.pex.config.Config` instances are equal. 1332 `False` if there is an inequality. 1336 lsst.pex.config.compareConfigs 1340 Unselected targets of `~lsst.pex.config.RegistryField` fields and 1341 unselected choices of `~lsst.pex.config.ConfigChoiceField` fields 1342 are not considered by this method. 1344 Floating point comparisons are performed by `numpy.allclose`. 1346 name1 = self._name
if self._name
is not None else "config" 1347 name2 = other._name
if other._name
is not None else "config" 1350 rtol=rtol, atol=atol, output=output)
def compareConfigs(name, c1, c2, shortcut=True, rtol=1E-8, atol=1E-8, output=None)
def getComparisonName(name1, name2)
◆ formatHistory()
def lsst.pex.config.config.Config.formatHistory |
( |
|
self, |
|
|
|
name, |
|
|
|
kwargs |
|
) |
| |
|
inherited |
Format a configuration field's history to a human-readable format.
Parameters
----------
name : `str`
Name of a `~lsst.pex.config.Field` in this config.
kwargs
Keyword arguments passed to `lsst.pex.config.history.format`.
Returns
-------
history : `str`
A string containing the formatted history.
See also
--------
lsst.pex.config.history.format
Definition at line 1221 of file config.py.
1221 def formatHistory(self, name, **kwargs):
1222 """Format a configuration field's history to a human-readable format. 1227 Name of a `~lsst.pex.config.Field` in this config. 1229 Keyword arguments passed to `lsst.pex.config.history.format`. 1234 A string containing the formatted history. 1238 lsst.pex.config.history.format 1241 return pexHist.format(self, name, **kwargs)
◆ freeze()
def lsst.pex.config.config.Config.freeze |
( |
|
self | ) |
|
|
inherited |
Make this config, and all subconfigs, read-only.
Definition at line 1088 of file config.py.
1089 """Make this config, and all subconfigs, read-only. 1092 for field
in self._fields.values():
◆ items()
def lsst.pex.config.config.Config.items |
( |
|
self | ) |
|
|
inherited |
Get configurations as ``(field name, field value)`` pairs.
Returns
-------
items : `list`
List of tuples for each configuration. Tuple items are:
0. Field name.
1. Field value.
See also
--------
lsst.pex.config.Config.iteritems
Definition at line 741 of file config.py.
742 """Get configurations as ``(field name, field value)`` pairs. 747 List of tuples for each configuration. Tuple items are: 754 lsst.pex.config.Config.iteritems std::vector< SchemaItem< Flag > > * items
daf::base::PropertyList * list
◆ iteritems()
def lsst.pex.config.config.Config.iteritems |
( |
|
self | ) |
|
|
inherited |
Iterate over (field name, field value) pairs.
Yields
------
item : `tuple`
Tuple items are:
0. Field name.
1. Field value.
See also
--------
lsst.pex.config.Config.items
Definition at line 758 of file config.py.
759 """Iterate over (field name, field value) pairs. 771 lsst.pex.config.Config.items 773 return iter(self._storage.
items())
std::vector< SchemaItem< Flag > > * items
◆ iterkeys()
def lsst.pex.config.config.Config.iterkeys |
( |
|
self | ) |
|
|
inherited |
Iterate over field names
Yields
------
key : `str`
A field's key (attribute name).
See also
--------
lsst.pex.config.Config.values
Definition at line 789 of file config.py.
790 """Iterate over field names 795 A field's key (attribute name). 799 lsst.pex.config.Config.values 801 return iter(self.storage.
keys())
◆ itervalues()
def lsst.pex.config.config.Config.itervalues |
( |
|
self | ) |
|
|
inherited |
Iterate over field values.
Yields
------
value : obj
A field value.
See also
--------
lsst.pex.config.Config.values
Definition at line 775 of file config.py.
775 def itervalues(self):
776 """Iterate over field values. 785 lsst.pex.config.Config.values 787 return iter(self.storage.values())
◆ keys()
def lsst.pex.config.config.Config.keys |
( |
|
self | ) |
|
|
inherited |
Get field names.
Returns
-------
names : `list`
List of `lsst.pex.config.Field` names.
See also
--------
lsst.pex.config.Config.iterkeys
Definition at line 713 of file config.py.
719 List of `lsst.pex.config.Field` names. 723 lsst.pex.config.Config.iterkeys
daf::base::PropertyList * list
◆ load()
def lsst.pex.config.config.Config.load |
( |
|
self, |
|
|
|
filename, |
|
|
|
root = "config" |
|
) |
| |
|
inherited |
Modify this config in place by executing the Python code in a
configuration file.
Parameters
----------
filename : `str`
Name of the configuration file. A configuration file is Python
module.
root : `str`, optional
Name of the variable in file that refers to the config being
overridden.
For example, the value of root is ``"config"`` and the file
contains::
config.myField = 5
Then this config's field ``myField`` is set to ``5``.
**Deprecated:** For backwards compatibility, older config files
that use ``root="root"`` instead of ``root="config"`` will be
loaded with a warning printed to `sys.stderr`. This feature will be
removed at some point.
See also
--------
lsst.pex.config.Config.loadFromStream
lsst.pex.config.Config.save
lsst.pex.config.Config.saveFromStream
Definition at line 928 of file config.py.
928 def load(self, filename, root="config"):
929 """Modify this config in place by executing the Python code in a 935 Name of the configuration file. A configuration file is Python 937 root : `str`, optional 938 Name of the variable in file that refers to the config being 941 For example, the value of root is ``"config"`` and the file 946 Then this config's field ``myField`` is set to ``5``. 948 **Deprecated:** For backwards compatibility, older config files 949 that use ``root="root"`` instead of ``root="config"`` will be 950 loaded with a warning printed to `sys.stderr`. This feature will be 951 removed at some point. 955 lsst.pex.config.Config.loadFromStream 956 lsst.pex.config.Config.save 957 lsst.pex.config.Config.saveFromStream 959 with open(filename,
"r") as f: 960 code = compile(f.read(), filename=filename, mode="exec")
961 self.loadFromStream(stream=code, root=root)
◆ loadFromStream()
def lsst.pex.config.config.Config.loadFromStream |
( |
|
self, |
|
|
|
stream, |
|
|
|
root = "config" , |
|
|
|
filename = None |
|
) |
| |
|
inherited |
Modify this Config in place by executing the Python code in the
provided stream.
Parameters
----------
stream : file-like object, `str`, or compiled string
Stream containing configuration override code.
root : `str`, optional
Name of the variable in file that refers to the config being
overridden.
For example, the value of root is ``"config"`` and the file
contains::
config.myField = 5
Then this config's field ``myField`` is set to ``5``.
**Deprecated:** For backwards compatibility, older config files
that use ``root="root"`` instead of ``root="config"`` will be
loaded with a warning printed to `sys.stderr`. This feature will be
removed at some point.
filename : `str`, optional
Name of the configuration file, or `None` if unknown or contained
in the stream. Used for error reporting.
See also
--------
lsst.pex.config.Config.load
lsst.pex.config.Config.save
lsst.pex.config.Config.saveFromStream
Definition at line 963 of file config.py.
963 def loadFromStream(self, stream, root="config", filename=None):
964 """Modify this Config in place by executing the Python code in the 969 stream : file-like object, `str`, or compiled string 970 Stream containing configuration override code. 971 root : `str`, optional 972 Name of the variable in file that refers to the config being 975 For example, the value of root is ``"config"`` and the file 980 Then this config's field ``myField`` is set to ``5``. 982 **Deprecated:** For backwards compatibility, older config files 983 that use ``root="root"`` instead of ``root="config"`` will be 984 loaded with a warning printed to `sys.stderr`. This feature will be 985 removed at some point. 986 filename : `str`, optional 987 Name of the configuration file, or `None` if unknown or contained 988 in the stream. Used for error reporting. 992 lsst.pex.config.Config.load 993 lsst.pex.config.Config.save 994 lsst.pex.config.Config.saveFromStream 996 with RecordingImporter()
as importer:
999 exec(stream, {}, local)
1000 except NameError
as e:
1001 if root ==
"config" and "root" in e.args[0]:
1002 if filename
is None:
1005 filename = getattr(stream,
"co_filename",
None)
1006 if filename
is None:
1007 filename = getattr(stream,
"name",
"?")
1008 print(f
"Config override file {filename!r}" 1009 " appears to use 'root' instead of 'config'; trying with 'root'", file=sys.stderr)
1010 local = {
"root": self}
1011 exec(stream, {}, local)
1015 self._imports.update(importer.getModules())
◆ names()
def lsst.pex.config.config.Config.names |
( |
|
self | ) |
|
|
inherited |
Get all the field names in the config, recursively.
Returns
-------
names : `list` of `str`
Field names.
Definition at line 1142 of file config.py.
1143 """Get all the field names in the config, recursively. 1147 names : `list` of `str` 1154 with io.StringIO()
as strFd:
1155 self.saveToStream(strFd,
"config")
1156 contents = strFd.getvalue()
1162 for line
in contents.split(
"\n"):
1163 if re.search(
r"^((assert|import)\s+|\s*$|#)", line):
1166 mat = re.search(
r"^(?:config\.)?([^=]+)\s*=\s*.*", line)
1168 keys.append(mat.group(1))
◆ save()
def lsst.pex.config.config.Config.save |
( |
|
self, |
|
|
|
filename, |
|
|
|
root = "config" |
|
) |
| |
|
inherited |
Save a Python script to the named file, which, when loaded,
reproduces this config.
Parameters
----------
filename : `str`
Desination filename of this configuration.
root : `str`, optional
Name to use for the root config variable. The same value must be
used when loading (see `lsst.pex.config.Config.load`).
See also
--------
lsst.pex.config.Config.saveToStream
lsst.pex.config.Config.load
lsst.pex.config.Config.loadFromStream
Definition at line 1017 of file config.py.
1017 def save(self, filename, root="config"):
1018 """Save a Python script to the named file, which, when loaded, 1019 reproduces this config. 1024 Desination filename of this configuration. 1025 root : `str`, optional 1026 Name to use for the root config variable. The same value must be 1027 used when loading (see `lsst.pex.config.Config.load`). 1031 lsst.pex.config.Config.saveToStream 1032 lsst.pex.config.Config.load 1033 lsst.pex.config.Config.loadFromStream 1035 d = os.path.dirname(filename)
1036 with tempfile.NamedTemporaryFile(mode=
"w", delete=
False, dir=d)
as outfile:
1037 self.saveToStream(outfile, root)
1041 umask = os.umask(0o077)
1043 os.chmod(outfile.name, (~umask & 0o666))
1047 shutil.move(outfile.name, filename)
◆ saveToStream()
def lsst.pex.config.config.Config.saveToStream |
( |
|
self, |
|
|
|
outfile, |
|
|
|
root = "config" |
|
) |
| |
|
inherited |
Save a configuration file to a stream, which, when loaded,
reproduces this config.
Parameters
----------
outfile : file-like object
Destination file object write the config into. Accepts strings not
bytes.
root
Name to use for the root config variable. The same value must be
used when loading (see `lsst.pex.config.Config.load`).
See also
--------
lsst.pex.config.Config.save
lsst.pex.config.Config.load
lsst.pex.config.Config.loadFromStream
Definition at line 1049 of file config.py.
1049 def saveToStream(self, outfile, root="config"):
1050 """Save a configuration file to a stream, which, when loaded, 1051 reproduces this config. 1055 outfile : file-like object 1056 Destination file object write the config into. Accepts strings not 1059 Name to use for the root config variable. The same value must be 1060 used when loading (see `lsst.pex.config.Config.load`). 1064 lsst.pex.config.Config.save 1065 lsst.pex.config.Config.load 1066 lsst.pex.config.Config.loadFromStream 1071 self._collectImports()
1073 self._imports.remove(self.__module__)
1074 configType =
type(self)
1075 typeString = _typeStr(configType)
1076 outfile.write(
u"import {}\n".
format(configType.__module__))
1077 outfile.write(
u"assert type({})=={}, 'config is of type %s.%s ".
format(root, typeString))
1078 outfile.write(
u"instead of {}' % (type({}).__module__, type({}).__name__)\n".
format(typeString,
1081 for imp
in self._imports:
1082 if imp
in sys.modules
and sys.modules[imp]
is not None:
1083 outfile.write(
u"import {}\n".
format(imp))
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
◆ setDefaults()
def lsst.pex.config.config.Config.setDefaults |
( |
|
self | ) |
|
|
inherited |
Subclass hook for computing defaults.
Notes
-----
Derived `~lsst.pex.config.Config` classes that must compute defaults
rather than using the `~lsst.pex.config.Field` instances's defaults
should do so here. To correctly use inherited defaults,
implementations of ``setDefaults`` must call their base class's
``setDefaults``.
Definition at line 855 of file config.py.
856 """Subclass hook for computing defaults. 860 Derived `~lsst.pex.config.Config` classes that must compute defaults 861 rather than using the `~lsst.pex.config.Field` instances's defaults 862 should do so here. To correctly use inherited defaults, 863 implementations of ``setDefaults`` must call their base class's
◆ toDict()
def lsst.pex.config.config.Config.toDict |
( |
|
self | ) |
|
|
inherited |
Make a dictionary of field names and their values.
Returns
-------
dict_ : `dict`
Dictionary with keys that are `~lsst.pex.config.Field` names.
Values are `~lsst.pex.config.Field` values.
See also
--------
lsst.pex.config.Field.toDict
Notes
-----
This method uses the `~lsst.pex.config.Field.toDict` method of
individual fields. Subclasses of `~lsst.pex.config.Field` may need to
implement a ``toDict`` method for *this* method to work.
Definition at line 1118 of file config.py.
1119 """Make a dictionary of field names and their values. 1124 Dictionary with keys that are `~lsst.pex.config.Field` names. 1125 Values are `~lsst.pex.config.Field` values. 1129 lsst.pex.config.Field.toDict 1133 This method uses the `~lsst.pex.config.Field.toDict` method of 1134 individual fields. Subclasses of `~lsst.pex.config.Field` may need to 1135 implement a ``toDict`` method for *this* method to work. 1138 for name, field
in self._fields.
items():
1139 dict_[name] = field.toDict(self)
std::vector< SchemaItem< Flag > > * items
◆ update()
def lsst.pex.config.config.Config.update |
( |
|
self, |
|
|
|
kw |
|
) |
| |
|
inherited |
Update values of fields specified by the keyword arguments.
Parameters
----------
kw
Keywords are configuration field names. Values are configuration
field values.
Notes
-----
The ``__at`` and ``__label`` keyword arguments are special internal
keywords. They are used to strip out any internal steps from the
history tracebacks of the config. Do not modify these keywords to
subvert a `~lsst.pex.config.Config` instance's history.
Examples
--------
This is a config with three fields:
>>> from lsst.pex.config import Config, Field
>>> class DemoConfig(Config):
... fieldA = Field(doc='Field A', dtype=int, default=42)
... fieldB = Field(doc='Field B', dtype=bool, default=True)
... fieldC = Field(doc='Field C', dtype=str, default='Hello world')
...
>>> config = DemoConfig()
These are the default values of each field:
>>> for name, value in config.iteritems():
... print(f"{name}: {value}")
...
fieldA: 42
fieldB: True
fieldC: 'Hello world'
Using this method to update ``fieldA`` and ``fieldC``:
>>> config.update(fieldA=13, fieldC='Updated!')
Now the values of each field are:
>>> for name, value in config.iteritems():
... print(f"{name}: {value}")
...
fieldA: 13
fieldB: True
fieldC: 'Updated!'
Definition at line 868 of file config.py.
868 def update(self, **kw):
869 """Update values of fields specified by the keyword arguments. 874 Keywords are configuration field names. Values are configuration 879 The ``__at`` and ``__label`` keyword arguments are special internal 880 keywords. They are used to strip out any internal steps from the 881 history tracebacks of the config. Do not modify these keywords to 882 subvert a `~lsst.pex.config.Config` instance's history. 886 This is a config with three fields: 888 >>> from lsst.pex.config import Config, Field 889 >>> class DemoConfig(Config): 890 ... fieldA = Field(doc='Field A', dtype=int, default=42) 891 ... fieldB = Field(doc='Field B', dtype=bool, default=True) 892 ... fieldC = Field(doc='Field C', dtype=str, default='Hello world') 894 >>> config = DemoConfig() 896 These are the default values of each field: 898 >>> for name, value in config.iteritems(): 899 ... print(f"{name}: {value}") 903 fieldC: 'Hello world' 905 Using this method to update ``fieldA`` and ``fieldC``: 907 >>> config.update(fieldA=13, fieldC='Updated!') 909 Now the values of each field are: 911 >>> for name, value in config.iteritems(): 912 ... print(f"{name}: {value}") 919 label = kw.pop(
"__label",
"update")
921 for name, value
in kw.items():
923 field = self._fields[name]
924 field.__set__(self, value, at=at, label=label)
926 raise KeyError(
"No field of name %s exists in config type %s" % (name, _typeStr(self)))
◆ validate()
def lsst.pex.config.config.Config.validate |
( |
|
self | ) |
|
|
inherited |
Validate the Config, raising an exception if invalid.
Raises
------
lsst.pex.config.FieldValidationError
Raised if verification fails.
Notes
-----
The base class implementation performs type checks on all fields by
calling their `~lsst.pex.config.Field.validate` methods.
Complex single-field validation can be defined by deriving new Field
types. For convenience, some derived `lsst.pex.config.Field`-types
(`~lsst.pex.config.ConfigField` and
`~lsst.pex.config.ConfigChoiceField`) are defined in `lsst.pex.config`
that handle recursing into subconfigs.
Inter-field relationships should only be checked in derived
`~lsst.pex.config.Config` classes after calling this method, and base
validation is complete.
Definition at line 1195 of file config.py.
1196 """Validate the Config, raising an exception if invalid. 1200 lsst.pex.config.FieldValidationError 1201 Raised if verification fails. 1205 The base class implementation performs type checks on all fields by 1206 calling their `~lsst.pex.config.Field.validate` methods. 1208 Complex single-field validation can be defined by deriving new Field 1209 types. For convenience, some derived `lsst.pex.config.Field`-types 1210 (`~lsst.pex.config.ConfigField` and 1211 `~lsst.pex.config.ConfigChoiceField`) are defined in `lsst.pex.config` 1212 that handle recursing into subconfigs. 1214 Inter-field relationships should only be checked in derived 1215 `~lsst.pex.config.Config` classes after calling this method, and base 1216 validation is complete. 1218 for field
in self._fields.values():
1219 field.validate(self)
◆ values()
def lsst.pex.config.config.Config.values |
( |
|
self | ) |
|
|
inherited |
Get field values.
Returns
-------
values : `list`
List of field values.
See also
--------
lsst.pex.config.Config.itervalues
Definition at line 727 of file config.py.
733 List of field values. 737 lsst.pex.config.Config.itervalues 739 return list(self._storage.values())
daf::base::PropertyList * list
◆ doMeasure
lsst.meas.base.baseMeasurement.BaseMeasurementPluginConfig.doMeasure |
|
staticinherited |
Initial value: doc="whether to run this plugin in single-object mode")
Definition at line 54 of file baseMeasurement.py.
◆ doMeasureN
bool lsst.meas.base.baseMeasurement.BaseMeasurementPluginConfig.doMeasureN = False |
|
staticinherited |
◆ history
lsst.pex.config.config.Config.history = property(lambda x: x._history) |
|
staticinherited |
The documentation for this class was generated from the following file:
- /j/snowflake/release/lsstsw/stack/Linux64/meas_base/18.1.0/python/lsst/meas/base/plugins.py