@File : _base_transformer.py @Time : 2026/05/18 10:57:45 @Author : Alejandro Marrero (amarrerd@ull.edu.es) @Version : 1.0 @Contact : amarrerd@ull.edu.es @License : (C)Copyright 2026, Alejandro Marrero @Desc : None

Transformer

Bases: ABC

Base class to type check all the transformer types in digneapy. A Transformer is any callable type that receives a sequence and transforms it to other sequence.

Source code in digneapy/transformers/_base_transformer.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class Transformer(ABC):
    """Base class to type check all the transformer types in digneapy.
    A Transformer is any callable type that receives a sequence and transforms it
    to other sequence.
    """

    def __init__(self, name: str):
        self._name = name

    @abstractmethod
    def __call__(self, x: np.ndarray | list[IndType]) -> np.ndarray: ...

    def train(self, x: np.ndarray | list[IndType]):
        raise NotImplementedError("train method not implemented in Transformer")

    def predict(self, x: np.ndarray | list[IndType]) -> np.ndarray:
        return self.__call__(x)

    def save(self):
        raise NotImplementedError("save method not implemented in Transformer")