pystencils.codegen.config.ConfigBase#
- class pystencils.codegen.config.ConfigBase#
Base class for configuration categories.
This class implements query and retrieval mechanism for configuration options, as well as deepcopy functionality for categories.
Subclasses of
ConfigBase
must bedataclasses
, and all of their instance fields must have one of two descriptors types: - EitherOption
, for scalar options; - OrCategory
for option subcategories.Option
fields must be assigned immutable values, but are otherwise unconstrained.Category
subobjects must be subclasses ofConfigBase
.Retrieval Options set to
None
are considered unset, i.e. the user has not provided a value. Through theOption
descriptor, these options can still have a default value. To retrieve either the user-set value if one exists, or the default value otherwise, useget_option
.Deep-Copy When a configuration object is copied, all of its subcategories must be copied along with it, such that changes in the original do no affect the copy, and vice versa. Such a deep copy is performed by the
copy
method.- get_option(name)#
Get the value set for the specified option, or the option’s default value if none has been set.
- copy()#
Perform a semi-deep copy of this configuration object.
This will recursively copy any config subobjects (categories, i.e. subclasses of
ConfigBase
wrapped in theCategory
descriptor) nested in this configuration object. Any other fields will be copied by reference.