import math import numpy as np class COMComponent: def __init__(self, epoch_size=100): self._epoch = epoch_size class Channel(COMComponent): """ Communication base module containing all model structure. This model is just empty therefore just bypasses any input to output """ def forward(self, values: np.ndarray) -> np.ndarray: """ :param values: value generator, each iteration returns tuple of (amplitude, phase, frequency) :return: affected tuple of (amplitude, phase, frequency) """ raise NotImplemented("Need to define forward function") class ModComponent(COMComponent): def __init__(self, alphabet_size, **kwargs): super().__init__(**kwargs) self.N = math.ceil(math.log2(alphabet_size)) self.alphabet_size = alphabet_size class Modulator(ModComponent): def forward(self, binary: np.ndarray) -> np.ndarray: """ :param binary: raw bytes as input (most be dtype=bool) :return: amplitude, phase, frequency """ raise NotImplemented("Need to define forward function") class Demodulator(ModComponent): def forward(self, values: np.ndarray) -> np.ndarray: """ :param values: value generator, each iteration returns tuple of (amplitude, phase, frequency) :return: binary resulting values (dtype=bool) """ raise NotImplemented("Need to define forward function")