mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
Further comparison operations and test implemented
This commit is contained in:
parent
8d7a5daafa
commit
0c83f7a607
2 changed files with 16 additions and 0 deletions
|
@ -485,9 +485,21 @@ class Obs:
|
|||
def __lt__(self, other):
|
||||
return self.value < other
|
||||
|
||||
def __le__(self, other):
|
||||
return self.value <= other
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.value > other
|
||||
|
||||
def __ge__(self, other):
|
||||
return self.value >= other
|
||||
|
||||
def __eq__(self, other):
|
||||
return (self - other).is_zero()
|
||||
|
||||
def __ne__(self, other):
|
||||
return not (self - other).is_zero()
|
||||
|
||||
# Overload math operations
|
||||
def __add__(self, y):
|
||||
if isinstance(y, Obs):
|
||||
|
|
|
@ -26,6 +26,10 @@ def test_comparison():
|
|||
test_obs2 = pe.pseudo_Obs(value2, 0.1, 't')
|
||||
assert (value1 > value2) == (test_obs1 > test_obs2)
|
||||
assert (value1 < value2) == (test_obs1 < test_obs2)
|
||||
assert (value1 >= value2) == (test_obs1 >= test_obs2)
|
||||
assert (value1 <= value2) == (test_obs1 <= test_obs2)
|
||||
assert test_obs1 == test_obs1
|
||||
assert test_obs1 != test_obs2
|
||||
|
||||
|
||||
def test_function_overloading():
|
||||
|
|
Loading…
Add table
Reference in a new issue