mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 01:53:31 +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):
|
def __setitem__(self, key, val):
|
||||||
self.x[key] = val
|
self.x[key] = val
|
||||||
|
|
||||||
|
# math
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
if isinstance(other, Location):
|
if isinstance(other, Location):
|
||||||
other = other.x
|
other = other.x
|
||||||
|
@ -40,12 +41,20 @@ class Location:
|
||||||
|
|
||||||
return self.__class__(self.x - other)
|
return self.__class__(self.x - other)
|
||||||
|
|
||||||
|
def __mul__(self, other):
|
||||||
|
return self.__class__(self.x * other)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, Location):
|
if isinstance(other, Location):
|
||||||
other = other.x
|
other = other.x
|
||||||
|
|
||||||
return np.all(self.x == other)
|
return np.all(self.x == other)
|
||||||
|
|
||||||
|
# math alias functions
|
||||||
|
__radd__ = __add__
|
||||||
|
__rsub__ = __sub__
|
||||||
|
__rmul__ = __mul__
|
||||||
|
|
||||||
class Receiver(Location):
|
class Receiver(Location):
|
||||||
"""
|
"""
|
||||||
A location able to trace a signal over time.
|
A location able to trace a signal over time.
|
||||||
|
|
Loading…
Reference in a new issue