mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
__eq__ method for Corr class (#206)
* feat: implemented __eq__ method for Corr class. * feat: __eq__ method now respects None entries in correlators. * feat: Obs can now be compared to None, __ne__ method removed as it is not required. * feat: Corr.__eq__ rewritten to give a per element comparison. * tests: additional test case for correlator comparison added. * feat: comparison now also works for padding.
This commit is contained in:
parent
1e438356fd
commit
af28f77ec5
4 changed files with 46 additions and 3 deletions
|
@ -1056,6 +1056,13 @@ class Corr:
|
|||
|
||||
__array_priority__ = 10000
|
||||
|
||||
def __eq__(self, y):
|
||||
if isinstance(y, Corr):
|
||||
comp = np.asarray(y.content, dtype=object)
|
||||
else:
|
||||
comp = np.asarray(y)
|
||||
return np.asarray(self.content, dtype=object) == comp
|
||||
|
||||
def __add__(self, y):
|
||||
if isinstance(y, Corr):
|
||||
if ((self.N != y.N) or (self.T != y.T)):
|
||||
|
|
|
@ -773,11 +773,10 @@ class Obs:
|
|||
return self.value >= other
|
||||
|
||||
def __eq__(self, other):
|
||||
if other is None:
|
||||
return False
|
||||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue