Merge branch 'develop' into documentation

This commit is contained in:
fjosw 2023-01-16 16:10:49 +00:00
commit c328274be6
2 changed files with 17 additions and 2 deletions

View file

@ -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):

View file

@ -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]