From 8d59a088f36c2247a3e6eeeab0352b916fd632df Mon Sep 17 00:00:00 2001 From: shubhrai23 Date: Wed, 12 Aug 2026 03:44:42 +0530 Subject: [PATCH 1/2] fix: normalize PersistenceLength by n_frames instead of trajectory n_frames --- package/MDAnalysis/analysis/polymer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/MDAnalysis/analysis/polymer.py b/package/MDAnalysis/analysis/polymer.py index 7a0510eab03..0d832d1198c 100644 --- a/package/MDAnalysis/analysis/polymer.py +++ b/package/MDAnalysis/analysis/polymer.py @@ -317,7 +317,7 @@ def fit(self): def _conclude(self): norm = np.linspace(self.chainlength - 1, 1, self.chainlength - 1) - norm *= len(self._atomgroups) * self._trajectory.n_frames + norm *= len(self._atomgroups) * self.n_frames self.results.bond_autocorrelation = ( self.results.raw_bond_autocorr / norm ) From 720cf66d68cb5b3943830b253f5343bb19ecc6a9 Mon Sep 17 00:00:00 2001 From: shubhrai23 Date: Sat, 15 Aug 2026 04:41:32 +0530 Subject: [PATCH 2/2] test: add test for PersistenceLength with partial trajectory run --- testsuite/MDAnalysisTests/analysis/test_persistencelength.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testsuite/MDAnalysisTests/analysis/test_persistencelength.py b/testsuite/MDAnalysisTests/analysis/test_persistencelength.py index 54005c8a667..cd11071ee39 100644 --- a/testsuite/MDAnalysisTests/analysis/test_persistencelength.py +++ b/testsuite/MDAnalysisTests/analysis/test_persistencelength.py @@ -72,6 +72,10 @@ def test_ag_ValueError(self, u): def test_run(self, p_run): assert len(p_run.results.bond_autocorrelation) == 280 + def test_run_partial(self, p): + p.run(start=0, stop=2) + assert_almost_equal(p.results.bond_autocorrelation[0], 1.0, 3) + def test_lb(self, p_run): assert_almost_equal(p_run.results.lb, 1.485, 3)