tarexp.base module#
The base module contains classes and functions that are inherited by
other TARexp classes.
- class tarexp.base.Eventable[source]#
Bases:
objectDeprecated since version 0.1.3: The Eventable class is plan to be removed in the future. It is not currently used by any classes. The event dispatcher of the
tarexp.experiments.Experimentis implemented in itself.
- class tarexp.base.Savable[source]#
Bases:
objectDefault Savable Class Mixin
Classes inheriting this class by default save itself has a gzipped pickle file. The files can be read by
tarexp.util.readObj.However, this is designed to be a catch-all method. Each class potentially would implement its own set of
saveandloadmethods, such astarexp.workflow.Workflow.save()andtarexp.workflow.Workflow.load().- save(path: Path | str, overwrite=False) Path[source]#
Saving the object
- Parameters:
path – Path to the output directory or filename. If a directory is provided, the filename is set to be the name of the class with extention
.pgz.overwrite – Whether to overwrite an existing file.
- Return type:
The path to the saved file.
- classmethod load(path: Path)[source]#
Class method for loading the saved file.
The method should be used as
{Class}.load(filename)which loads the saved content as a{Class}instance with type checking.- Parameters:
path – Path to the output directory or filename. If a directory is provided, it looks for a name of the class with extention
.pgz.- Return type:
An instance of the evoked class.
- class tarexp.base.space(data={})[source]#
Bases:
NamespaceHashable Namespace for Parameters.
It is an extension of argparse.Namespace that supports better
__repr__method and being hashable with a stable hash function based on the content.This class support direct access to the key-value content by attributes and items. Common dictionary interfaces such as
.keys()and.items()are also implemented.Caution
The content should all be hashable or at least the representation (
.__repr__()) should uniquely identify the object. It is being used to distinguish experiment runs intarexp.experiments.Experimentby comparing the identifier of thetarexp.component.Component.- keys()[source]#
- Returns:
Sorted tuple of the existing keys in the instance. Similar to the built-in
.keys()method for Python dictionaries.- Return type:
Tuple[Any]
- tarexp.base.easy_repr(cls)[source]#
Decorator for class to have a better
__repr__If attribute
configexists, it is used as the representation (unique identifier of the instance). If not, it creates a py:class:tarexp.util.space instance for the non-callable attributes for building the representation. Attributes starts with_are ignored.