New method is_zero

This commit is contained in:
Fabian Joswig 2021-10-17 12:28:59 +01:00
parent 573d4992c9
commit 10b228d434
3 changed files with 6 additions and 3 deletions

View file

@ -148,7 +148,7 @@ class Corr:
if self.T % 2 != 0:
raise Exception("Can not symmetrize odd T")
if not all([o.zero_within_error() for o in self.content[0]]):
if not all([o.is_zero_within_error() for o in self.content[0]]):
warnings.warn("Correlator does not seem to be anti-symmetric around x0=0.", RuntimeWarning)
newcontent = [self.content[0]]

View file

@ -341,9 +341,12 @@ class Obs:
for e_name in self.e_names:
print(e_name, ':', self.e_content[e_name])
def zero_within_error(self):
def is_zero_within_error(self):
return np.abs(self.value) <= self.dvalue
def is_zero(self):
np.isclose(0.0, self.value) and all(np.allclose(0.0, delta) for delta in self.deltas.values())
def plot_tauint(self, save=None):
"""Plot integrated autocorrelation time for each ensemble."""
if not self.e_names:

View file

@ -177,7 +177,7 @@ def test_utils():
my_obs.print(0)
my_obs.print(1)
my_obs.print(2)
assert not my_obs.zero_within_error()
assert not my_obs.is_zero_within_error()
my_obs.plot_tauint()
my_obs.plot_rho()
my_obs.plot_rep_dist()