Skip to content

Commit 5c11b50

Browse files
authored
Einstein msd verbose fix (#5153)
Replace bare `tqdm` with `ProgressBar` in `msd.py` - fix #5144 - replaces bare `tqdm` with `ProgressBar` for `analysis/msd.py` - adds appropriate `desc` for nested progressbars - CHANGELOG updated
1 parent 6b51eac commit 5c11b50

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

package/AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ Chronological list of authors
263263
- Amruthesh Thirumalaiswamy
264264
- Ch Zhang
265265
- Raúl Lois-Cuns
266+
- Shreejan Dolai
266267

267268
External code
268269
-------------

package/CHANGELOG

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ Changes
3131
Deprecations
3232

3333

34+
11/24/25 IAlibay, orbeckst, marinegor, tylerjereddy, ljwoods2, marinegor, spyke7
35+
36+
* 2.11.0
37+
38+
Fixes
39+
* Fixes the verbose=False in EinsteinMSD, and only shows progress bar when
40+
verbose=True (Issue #5144, PR #5153)
41+
42+
Changes
43+
* The msd.py inside analysis is changed, and ProgressBar is implemented inside
44+
_conclude_simple and _conclude_fft functions instead of tqdm (Issue #5144, PR #5153)
45+
46+
Deprecations
47+
48+
3449
10/18/25 IAlibay, orbeckst, BHM-Bob, TRY-ER, Abdulrahman-PROG, pbuslaev,
3550
yuxuanzhuang, yuyuan871111, tanishy7777, tulga-rdn, Gareth-elliott,
3651
hmacdope, tylerjereddy, cbouy, talagayev, DrDomenicoMarson, amruthesht,

package/MDAnalysis/analysis/msd.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,8 @@
247247
import numpy as np
248248
import logging
249249
from ..due import due, Doi
250-
from .base import AnalysisBase
250+
from .base import AnalysisBase, ProgressBar
251251
from ..core import groups
252-
from tqdm import tqdm
253252
import collections
254253

255254
logger = logging.getLogger("MDAnalysis.analysis.msd")
@@ -416,7 +415,11 @@ def _conclude_simple(self):
416415
r"""Calculates the MSD via the simple "windowed" algorithm."""
417416
lagtimes = np.arange(1, self.n_frames)
418417
positions = self._position_array.astype(np.float64)
419-
for lag in tqdm(lagtimes):
418+
for lag in ProgressBar(
419+
lagtimes,
420+
verbose=self._verbose,
421+
desc="Calculating MSD for lagtimes",
422+
):
420423
disp = positions[:-lag, :, :] - positions[lag:, :, :]
421424
sqdist = np.square(disp).sum(axis=-1)
422425
self.results.msds_by_particle[lag, :] = np.mean(sqdist, axis=0)
@@ -443,7 +446,11 @@ def _conclude_fft(self): # with FFT, np.float64 bit prescision required.
443446
)
444447

445448
positions = self._position_array.astype(np.float64)
446-
for n in tqdm(range(self.n_particles)):
449+
for n in ProgressBar(
450+
range(self.n_particles),
451+
verbose=self._verbose,
452+
desc="Calculating MSD with FFT per particle",
453+
):
447454
self.results.msds_by_particle[:, n] = tidynamics.msd(
448455
positions[:, n, :]
449456
)

0 commit comments

Comments
 (0)