pystencils.codegen.config.ConfigBase

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 be dataclasses, and all of their instance fields must have one of two descriptors types: - Either Option, for scalar options; - Or Category for option subcategories.

Option fields must be assigned immutable values, but are otherwise unconstrained. Category subobjects must be subclasses of ConfigBase.

Retrieval Options set to None are considered unset, i.e. the user has not provided a value. Through the Option descriptor, these options can still have a default value. To retrieve either the user-set value if one exists, or the default value otherwise, use get_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.

Return type:

Any

Parameters:

name (str)

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 the Category descriptor) nested in this configuration object. Any other fields will be copied by reference.