From 3c3fd70ce506a5935032ee1372b73082fb69a405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruaidhr=C3=AD?= Date: Fri, 17 Oct 2025 19:52:08 +0100 Subject: [PATCH] pyerrors/correlators.py: Allowing for None values in pe.Corr.prune Closes: fjosw#271 --- pyerrors/correlators.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pyerrors/correlators.py b/pyerrors/correlators.py index 0375155f..fb14d6d1 100644 --- a/pyerrors/correlators.py +++ b/pyerrors/correlators.py @@ -1405,13 +1405,15 @@ class Corr: tmpmat = np.empty((Ntrunc, Ntrunc), dtype=object) rmat = [] for t in range(basematrix.T): - for i in range(Ntrunc): - for j in range(Ntrunc): - tmpmat[i][j] = evecs[i].T @ self[t] @ evecs[j] - rmat.append(np.copy(tmpmat)) + if self.content[t] is None: + rmat.append(None) + else: + for i in range(Ntrunc): + for j in range(Ntrunc): + tmpmat[i][j] = evecs[i].T @ self[t] @ evecs[j] + rmat.append(np.copy(tmpmat)) - newcontent = [None if (self.content[t] is None) else rmat[t] for t in range(self.T)] - return Corr(newcontent) + return Corr(rmat) def _sort_vectors(vec_set_in, ts):