mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-12-22 11:33:32 +01:00
Allow Locations to be multiplied
This commit is contained in:
parent
8d57fa5aa5
commit
c4382f3eb2
1 changed files with 9 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue