from functools import partial try: from .location import Location except ImportError: from location import Location class Antenna(Location): """ A location able to interact with a signal. Either emitting or receiving. Optionally applies a transformation to the traced signal. """ def __repr__(self): return "Antenna({})".format(repr(self.x)) def recv(self, travel_signal: callable) -> callable: """ Return a function that traces the signal as a function of time at the antenna's location """ return partial(travel_signal, x_f=self.x) receive = recv def emit(self, travel_signal: callable) -> callable: return partial(travel_signal, x_0=self.x) class Receiver(Antenna): """ An antenna which main purpose is to trace a signal over time. Optionally applies a transformation to the traced signal. """ def __repr__(self): return "Receiver({})".format(repr(self.x)) class Emitter(Antenna): """ An antenna which main purpose is to emit a signal. """ def __repr__(self): return "Emitter({})".format(repr(self.x))