mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01:00
fix: Corr.matrix_symmetric now also works if entries of the correlators
are arrays with at least one None entry.
This commit is contained in:
parent
8a911cac61
commit
78f576a35e
2 changed files with 21 additions and 1 deletions
|
@ -236,7 +236,7 @@ class Corr:
|
|||
def matrix_symmetric(self):
|
||||
"""Symmetrizes the correlator matrices on every timeslice."""
|
||||
if self.N > 1:
|
||||
transposed = [None if (G is None) else G.T for G in self.content]
|
||||
transposed = [None if len(list(filter(None, np.asarray(G).flatten()))) < self.N ** 2 else G.T for G in self.content]
|
||||
return 0.5 * (Corr(transposed) + self)
|
||||
if self.N == 1:
|
||||
raise Exception("Trying to symmetrize a correlator matrix, that already has N=1.")
|
||||
|
|
|
@ -332,6 +332,15 @@ def test_matrix_symmetric():
|
|||
|
||||
assert np.all([np.all(o == o.T) for o in sym_corr_mat])
|
||||
|
||||
t_obs = pe.pseudo_Obs(1.0, 0.1, 'test')
|
||||
o_mat = np.array([[t_obs, t_obs], [t_obs, t_obs]])
|
||||
corr1 = pe.Corr([o_mat, None, o_mat])
|
||||
corr2 = pe.Corr([o_mat, np.array([[None, None], [None, None]]), o_mat])
|
||||
corr3 = pe.Corr([o_mat, np.array([[t_obs, None], [None, t_obs]], dtype=object), o_mat])
|
||||
corr1.matrix_symmetric()
|
||||
corr2.matrix_symmetric()
|
||||
corr3.matrix_symmetric()
|
||||
|
||||
|
||||
def test_GEVP_solver():
|
||||
|
||||
|
@ -347,6 +356,17 @@ def test_GEVP_solver():
|
|||
assert np.allclose(sp_vecs, pe.correlators._GEVP_solver(mat1, mat2), atol=1e-14)
|
||||
|
||||
|
||||
def test_GEVP_none_entries():
|
||||
t_obs = pe.pseudo_Obs(1.0, 0.1, 'test')
|
||||
t_obs2 = pe.pseudo_Obs(0.1, 0.1, 'test')
|
||||
|
||||
o_mat = np.array([[t_obs, t_obs2], [t_obs2, t_obs2]])
|
||||
n_arr = np.array([[None, None], [None, None]])
|
||||
|
||||
corr = pe.Corr([o_mat, o_mat, o_mat, o_mat, o_mat, o_mat, None, o_mat, n_arr, None, o_mat])
|
||||
corr.GEVP(t0=2)
|
||||
|
||||
|
||||
def test_hankel():
|
||||
corr_content = []
|
||||
for t in range(8):
|
||||
|
|
Loading…
Add table
Reference in a new issue