From 3e955d49765b02ebdc9e54680225cbf64be34e2b Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Fri, 10 Oct 2025 17:38:02 +0200 Subject: [PATCH 1/3] [chore] Bump version to 2.16.0-dev --- pyerrors/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyerrors/version.py b/pyerrors/version.py index 90c1ae3a..e017dc17 100644 --- a/pyerrors/version.py +++ b/pyerrors/version.py @@ -1 +1 @@ -__version__ = "2.15.0" +__version__ = "2.16.0-dev" From e0bfcabc0c945c840c744ebcfc47fbcc76eb2edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruaidhr=C3=AD?= <79585079+campioru@users.noreply.github.com> Date: Sun, 19 Oct 2025 11:28:36 +0100 Subject: [PATCH 2/3] pyerrors/correlators.py: Allowing for None values in pe.Corr.prune (#272) * pyerrors/correlators.py: Allowing for None values in pe.Corr.prune Closes: fjosw#271 * wip * test/correlators_test.py: Adding test for updated prune method. Closes #271 --- pyerrors/correlators.py | 14 ++++++++------ tests/correlators_test.py | 23 +++++++++++++++++++++++ 2 files changed, 31 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): diff --git a/tests/correlators_test.py b/tests/correlators_test.py index fc3528d2..cd629275 100644 --- a/tests/correlators_test.py +++ b/tests/correlators_test.py @@ -781,3 +781,26 @@ def test_complex_add_and_mul(): cc += 2j cc = cc * 4j cc.real + cc.imag + + +def test_prune_with_Nones(): + N = 3 + T = 10 + + front_padding = 1 + back_padding = T // 2 + + Ntrunc = N - 1 + t0proj = 2 + tproj = 3 + + corr_content = np.array([[[pe.pseudo_Obs((i+j+1)**(-t), .01, "None_prune_test") for i in range(N)] for j in range(N)] for t in range(T // 2 - front_padding)]) + unpadded_corr = pe.Corr(corr_content) + padded_corr = pe.Corr(corr_content, padding=[front_padding, back_padding]) + + tmp_corr = unpadded_corr.prune(Ntrunc, t0proj=t0proj-front_padding, tproj=tproj-front_padding) + pruned_then_padded = pe.Corr(tmp_corr.content, padding=[front_padding, back_padding]) + padded_then_pruned = padded_corr.prune(Ntrunc, t0proj=t0proj, tproj=tproj) + + for t in range(T): + assert np.all(pruned_then_padded.content[t] == padded_then_pruned.content[t]) From 1d031d0eabfb7978feb318fd1500556250d57c04 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Sun, 19 Oct 2025 12:29:45 +0200 Subject: [PATCH 3/3] [chore] Bump version and update changelog --- CHANGELOG.md | 5 +++++ pyerrors/version.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d6950c0..42dd7bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. +## [2.15.1] - 2025-10-19 + +### Fixed +- Fixed handling of padding in Correlator prune method. + ## [2.15.0] - 2025-10-10 ### Added diff --git a/pyerrors/version.py b/pyerrors/version.py index e017dc17..b1b26975 100644 --- a/pyerrors/version.py +++ b/pyerrors/version.py @@ -1 +1 @@ -__version__ = "2.16.0-dev" +__version__ = "2.15.1"