mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01:00
fix: Corr.symmetric can now deal with None entries. (#145)
This commit is contained in:
parent
26447d658c
commit
88fd37b241
2 changed files with 17 additions and 2 deletions
|
@ -201,8 +201,9 @@ class Corr:
|
|||
if self.T % 2 != 0:
|
||||
raise Exception("Can not symmetrize odd T")
|
||||
|
||||
if np.argmax(np.abs(self.content)) != 0:
|
||||
warnings.warn("Correlator does not seem to be symmetric around x0=0.", RuntimeWarning)
|
||||
if self.content[0] is not None:
|
||||
if np.argmax(np.abs([o[0].value if o is not None else 0 for o in self.content])) != 0:
|
||||
warnings.warn("Correlator does not seem to be symmetric around x0=0.", RuntimeWarning)
|
||||
|
||||
newcontent = [self.content[0]]
|
||||
for t in range(1, self.T):
|
||||
|
|
|
@ -552,3 +552,17 @@ def test_corr_no_filtering():
|
|||
b = pe.pseudo_Obs(1, 1e-11, 'a', samples=30)
|
||||
c *= b
|
||||
assert np.all([c[0].idl == o.idl for o in c])
|
||||
|
||||
|
||||
def test_corr_symmetric():
|
||||
obs = []
|
||||
for _ in range(4):
|
||||
obs.append(pe.pseudo_Obs(np.random.rand(), 0.1, "test"))
|
||||
|
||||
for corr in [pe.Corr([obs[0] + 8, obs[1], obs[2], obs[3]]),
|
||||
pe.Corr([obs[0] + 8, obs[1], obs[2], None]),
|
||||
pe.Corr([None, obs[1], obs[2], obs[3]])]:
|
||||
scorr = corr.symmetric()
|
||||
assert scorr[1] == scorr[3]
|
||||
assert scorr[2] == corr[2]
|
||||
assert scorr[0] == corr[0]
|
||||
|
|
Loading…
Add table
Reference in a new issue