Source code for chemprop.featurizers.base
from abc import abstractmethod
from collections.abc import Sized
from typing import Generic, TypeVar
import numpy as np
from chemprop.data.molgraph import MolGraph
S = TypeVar("S")
T = TypeVar("T")
[docs]
class Featurizer(Generic[S, T]):
"""An :class:`Featurizer` featurizes inputs type ``S`` into outputs of
type ``T``."""
[docs]
@abstractmethod
def __call__(self, input: S, *args, **kwargs) -> T:
"""featurize an input"""
[docs]
class VectorFeaturizer(Featurizer[S, np.ndarray], Sized):
...
[docs]
class GraphFeaturizer(Featurizer[S, MolGraph]):
@property
@abstractmethod
def shape(self) -> tuple[int, int]:
...