diff --git a/pyerrors/pyerrors.py b/pyerrors/pyerrors.py index fa30c0f4..2da2ae28 100644 --- a/pyerrors/pyerrors.py +++ b/pyerrors/pyerrors.py @@ -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): diff --git a/tests/test_pyerrors.py b/tests/test_pyerrors.py index 982dcab3..5d7fa48a 100644 --- a/tests/test_pyerrors.py +++ b/tests/test_pyerrors.py @@ -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():