Skip to content

Commit 6c7daac

Browse files
committed
Merge branch 'develop'
2 parents dbe5912 + 1d031d0 commit 6c7daac

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [2.15.1] - 2025-10-19
6+
7+
### Fixed
8+
- Fixed handling of padding in Correlator prune method.
9+
510
## [2.15.0] - 2025-10-10
611

712
### Added

pyerrors/correlators.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,13 +1405,15 @@ def prune(self, Ntrunc, tproj=3, t0proj=2, basematrix=None):
14051405
tmpmat = np.empty((Ntrunc, Ntrunc), dtype=object)
14061406
rmat = []
14071407
for t in range(basematrix.T):
1408-
for i in range(Ntrunc):
1409-
for j in range(Ntrunc):
1410-
tmpmat[i][j] = evecs[i].T @ self[t] @ evecs[j]
1411-
rmat.append(np.copy(tmpmat))
1408+
if self.content[t] is None:
1409+
rmat.append(None)
1410+
else:
1411+
for i in range(Ntrunc):
1412+
for j in range(Ntrunc):
1413+
tmpmat[i][j] = evecs[i].T @ self[t] @ evecs[j]
1414+
rmat.append(np.copy(tmpmat))
14121415

1413-
newcontent = [None if (self.content[t] is None) else rmat[t] for t in range(self.T)]
1414-
return Corr(newcontent)
1416+
return Corr(rmat)
14151417

14161418

14171419
def _sort_vectors(vec_set_in, ts):

pyerrors/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.15.0"
1+
__version__ = "2.15.1"

tests/correlators_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,3 +781,26 @@ def test_complex_add_and_mul():
781781
cc += 2j
782782
cc = cc * 4j
783783
cc.real + cc.imag
784+
785+
786+
def test_prune_with_Nones():
787+
N = 3
788+
T = 10
789+
790+
front_padding = 1
791+
back_padding = T // 2
792+
793+
Ntrunc = N - 1
794+
t0proj = 2
795+
tproj = 3
796+
797+
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)])
798+
unpadded_corr = pe.Corr(corr_content)
799+
padded_corr = pe.Corr(corr_content, padding=[front_padding, back_padding])
800+
801+
tmp_corr = unpadded_corr.prune(Ntrunc, t0proj=t0proj-front_padding, tproj=tproj-front_padding)
802+
pruned_then_padded = pe.Corr(tmp_corr.content, padding=[front_padding, back_padding])
803+
padded_then_pruned = padded_corr.prune(Ntrunc, t0proj=t0proj, tproj=tproj)
804+
805+
for t in range(T):
806+
assert np.all(pruned_then_padded.content[t] == padded_then_pruned.content[t])

0 commit comments

Comments
 (0)