/
_algorithm.py
34 lines (22 loc) · 1.19 KB
/
_algorithm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Public base classes for all algorithms and pipelines."""
from __future__ import annotations
from typing import ClassVar, Tuple, TypeVar, Union
from tpcp._base import BaseTpcpObject
AlgorithmT = TypeVar("AlgorithmT", bound="Algorithm")
class Algorithm(BaseTpcpObject):
"""Base class for all algorithms.
All type-specific algorithm classes should inherit from this class and need to
1. overwrite `_action_method` with the name of the actual action method of this class type
2. implement a stub for the action method
If you want to create an optimizable algorithm, add a `self_optimize` or (`self_optimize_with_info`) method to your
class.
We do not provide a separate base class for that, as we can make no assumptions about the call signature of your
custom `self_optimize` method.
If you need an "optimizable" version for a group of algorithms you are working with, create a custom
`OptimizableAlgorithm` class or `OptimizableAlgorithmMixing` that is specific to your algorithm.
Attributes
----------
_action_methods
The name(s) of the action method used by the child class
"""
_action_methods: ClassVar[Union[Tuple[str, ...], str]]