Allow Locations to be multiplied

This commit is contained in:
Eric Teunis de Boone 2022-03-10 17:01:54 +01:00
parent 8d57fa5aa5
commit c4382f3eb2

View file

@ -28,6 +28,7 @@ class Location:
def __setitem__(self, key, val):
self.x[key] = val
# math
def __add__(self, other):
if isinstance(other, Location):
other = other.x
@ -40,12 +41,20 @@ class Location:
return self.__class__(self.x - other)
def __mul__(self, other):
return self.__class__(self.x * other)
def __eq__(self, other):
if isinstance(other, Location):
other = other.x
return np.all(self.x == other)
# math alias functions
__radd__ = __add__
__rsub__ = __sub__
__rmul__ = __mul__
class Receiver(Location):
"""
A location able to trace a signal over time.