From 7c36d7cc851ea2a7d52bc25b5d9821c80f50f732 Mon Sep 17 00:00:00 2001 From: SophiaRuan Date: Tue, 14 Mar 2023 00:44:57 -0700 Subject: [PATCH 1/8] add progress bars --- package/MDAnalysis/analysis/msd.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/package/MDAnalysis/analysis/msd.py b/package/MDAnalysis/analysis/msd.py index 6c3104a9ce6..d85019ca3f2 100644 --- a/package/MDAnalysis/analysis/msd.py +++ b/package/MDAnalysis/analysis/msd.py @@ -387,10 +387,19 @@ def _conclude_simple(self): """ lagtimes = np.arange(1, self.n_frames) positions = self._position_array.astype(np.float64) + + # progressbar + import progressbar + import time + widgets = ['Loading: ', progressbar.AnimatedMarker()] + bar = progressbar.ProgressBar(widgets=widgets).start() + for lag in lagtimes: disp = positions[:-lag, :, :] - positions[lag:, :, :] sqdist = np.square(disp).sum(axis=-1) self.results.msds_by_particle[lag, :] = np.mean(sqdist, axis=0) + time.sleep(0.01) + bar.update(lag) self.results.timeseries = self.results.msds_by_particle.mean(axis=1) def _conclude_fft(self): # with FFT, np.float64 bit prescision required. @@ -411,7 +420,16 @@ def _conclude_fft(self): # with FFT, np.float64 bit prescision required. or set fft=False""") positions = self._position_array.astype(np.float64) + + # progressbar + import progressbar + import time + widgets = ['Loading: ', progressbar.AnimatedMarker()] + bar = progressbar.ProgressBar(widgets=widgets).start() + for n in range(self.n_particles): self.results.msds_by_particle[:, n] = tidynamics.msd( positions[:, n, :]) + time.sleep(0.01) + bar.update(n) self.results.timeseries = self.results.msds_by_particle.mean(axis=1) From f41138b12107871f12abda2fc26891793e80edfa Mon Sep 17 00:00:00 2001 From: SophiaRuan Date: Tue, 14 Mar 2023 01:27:46 -0700 Subject: [PATCH 2/8] update pbar maxval --- package/MDAnalysis/analysis/msd.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/package/MDAnalysis/analysis/msd.py b/package/MDAnalysis/analysis/msd.py index d85019ca3f2..d8bead26386 100644 --- a/package/MDAnalysis/analysis/msd.py +++ b/package/MDAnalysis/analysis/msd.py @@ -389,16 +389,17 @@ def _conclude_simple(self): positions = self._position_array.astype(np.float64) # progressbar - import progressbar - import time - widgets = ['Loading: ', progressbar.AnimatedMarker()] - bar = progressbar.ProgressBar(widgets=widgets).start() + from progressbar import Percentage, ProgressBar,Bar,ETA + bar = ProgressBar(widgets=[Bar('=', '[', ']'), ' ', + Percentage(), ' ', + ETA()], + maxval=self.n_frames).start() + for lag in lagtimes: disp = positions[:-lag, :, :] - positions[lag:, :, :] sqdist = np.square(disp).sum(axis=-1) self.results.msds_by_particle[lag, :] = np.mean(sqdist, axis=0) - time.sleep(0.01) bar.update(lag) self.results.timeseries = self.results.msds_by_particle.mean(axis=1) @@ -422,14 +423,14 @@ def _conclude_fft(self): # with FFT, np.float64 bit prescision required. positions = self._position_array.astype(np.float64) # progressbar - import progressbar - import time - widgets = ['Loading: ', progressbar.AnimatedMarker()] - bar = progressbar.ProgressBar(widgets=widgets).start() + from progressbar import Percentage, ProgressBar,Bar,ETA + bar = ProgressBar(widgets=[Bar('=', '[', ']'), ' ', + Percentage(), ' ', + ETA()], + maxval=self.n_particles).start() for n in range(self.n_particles): self.results.msds_by_particle[:, n] = tidynamics.msd( positions[:, n, :]) - time.sleep(0.01) bar.update(n) self.results.timeseries = self.results.msds_by_particle.mean(axis=1) From b3055ef87960357bfb0a653d6491560f01e89bbb Mon Sep 17 00:00:00 2001 From: SophiaRuan Date: Tue, 14 Mar 2023 01:38:13 -0700 Subject: [PATCH 3/8] fix format --- package/MDAnalysis/analysis/msd.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/package/MDAnalysis/analysis/msd.py b/package/MDAnalysis/analysis/msd.py index d8bead26386..dfdbe758c64 100644 --- a/package/MDAnalysis/analysis/msd.py +++ b/package/MDAnalysis/analysis/msd.py @@ -389,13 +389,10 @@ def _conclude_simple(self): positions = self._position_array.astype(np.float64) # progressbar - from progressbar import Percentage, ProgressBar,Bar,ETA + from progressbar import Percentage, ProgressBar, Bar, ETA bar = ProgressBar(widgets=[Bar('=', '[', ']'), ' ', - Percentage(), ' ', - ETA()], + Percentage(), ' ', ETA()], maxval=self.n_frames).start() - - for lag in lagtimes: disp = positions[:-lag, :, :] - positions[lag:, :, :] sqdist = np.square(disp).sum(axis=-1) @@ -423,12 +420,10 @@ def _conclude_fft(self): # with FFT, np.float64 bit prescision required. positions = self._position_array.astype(np.float64) # progressbar - from progressbar import Percentage, ProgressBar,Bar,ETA + from progressbar import Percentage, ProgressBar, Bar, ETA bar = ProgressBar(widgets=[Bar('=', '[', ']'), ' ', - Percentage(), ' ', - ETA()], + Percentage(), ' ', ETA()], maxval=self.n_particles).start() - for n in range(self.n_particles): self.results.msds_by_particle[:, n] = tidynamics.msd( positions[:, n, :]) From 5e66445d6f60bc1f78329669db15b0009da6a3c0 Mon Sep 17 00:00:00 2001 From: SophiaRuan Date: Tue, 14 Mar 2023 14:58:03 -0700 Subject: [PATCH 4/8] use tqdm --- package/MDAnalysis/analysis/msd.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/package/MDAnalysis/analysis/msd.py b/package/MDAnalysis/analysis/msd.py index dfdbe758c64..586ab98fb0c 100644 --- a/package/MDAnalysis/analysis/msd.py +++ b/package/MDAnalysis/analysis/msd.py @@ -389,15 +389,11 @@ def _conclude_simple(self): positions = self._position_array.astype(np.float64) # progressbar - from progressbar import Percentage, ProgressBar, Bar, ETA - bar = ProgressBar(widgets=[Bar('=', '[', ']'), ' ', - Percentage(), ' ', ETA()], - maxval=self.n_frames).start() - for lag in lagtimes: + from tqdm import tqdm + for lag in tqdm(lagtimes): disp = positions[:-lag, :, :] - positions[lag:, :, :] sqdist = np.square(disp).sum(axis=-1) self.results.msds_by_particle[lag, :] = np.mean(sqdist, axis=0) - bar.update(lag) self.results.timeseries = self.results.msds_by_particle.mean(axis=1) def _conclude_fft(self): # with FFT, np.float64 bit prescision required. @@ -420,12 +416,8 @@ def _conclude_fft(self): # with FFT, np.float64 bit prescision required. positions = self._position_array.astype(np.float64) # progressbar - from progressbar import Percentage, ProgressBar, Bar, ETA - bar = ProgressBar(widgets=[Bar('=', '[', ']'), ' ', - Percentage(), ' ', ETA()], - maxval=self.n_particles).start() - for n in range(self.n_particles): + from tqdm import tqdm + for n in tqdm(range(self.n_particles)): self.results.msds_by_particle[:, n] = tidynamics.msd( positions[:, n, :]) - bar.update(n) self.results.timeseries = self.results.msds_by_particle.mean(axis=1) From 3b2ac297845d9a926cce42c386ac1a11a630da6c Mon Sep 17 00:00:00 2001 From: SophiaRuan Date: Wed, 15 Mar 2023 13:33:57 -0700 Subject: [PATCH 5/8] move import of tqdm up --- package/MDAnalysis/analysis/msd.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/package/MDAnalysis/analysis/msd.py b/package/MDAnalysis/analysis/msd.py index 586ab98fb0c..c3d202e883a 100644 --- a/package/MDAnalysis/analysis/msd.py +++ b/package/MDAnalysis/analysis/msd.py @@ -250,6 +250,7 @@ from ..due import due, Doi from .base import AnalysisBase from ..core import groups +from tqdm import tqdm logger = logging.getLogger('MDAnalysis.analysis.msd') @@ -387,9 +388,6 @@ def _conclude_simple(self): """ lagtimes = np.arange(1, self.n_frames) positions = self._position_array.astype(np.float64) - - # progressbar - from tqdm import tqdm for lag in tqdm(lagtimes): disp = positions[:-lag, :, :] - positions[lag:, :, :] sqdist = np.square(disp).sum(axis=-1) @@ -414,9 +412,6 @@ def _conclude_fft(self): # with FFT, np.float64 bit prescision required. or set fft=False""") positions = self._position_array.astype(np.float64) - - # progressbar - from tqdm import tqdm for n in tqdm(range(self.n_particles)): self.results.msds_by_particle[:, n] = tidynamics.msd( positions[:, n, :]) From 27c49721adca8a03036211a8f84c9570a7bb4492 Mon Sep 17 00:00:00 2001 From: SophiaRuan Date: Mon, 20 Mar 2023 17:13:13 -0700 Subject: [PATCH 6/8] changelog --- package/CHANGELOG | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/package/CHANGELOG b/package/CHANGELOG index fb72be82d6e..93d7965f46e 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -13,7 +13,15 @@ The rules for this file: * release numbers follow "Semantic Versioning" http://semver.org ------------------------------------------------------------------------------ - + +03/20/23 SophiaRuan + +* 2.5.0 + +Changes + * Add progress bar to track the progress of _conclude() functions (_conclude_simple() and _conclude_fft()) in msd.py (PR #4072) + + ??/??/?? IAlibay, pgbarletta, mglagolev, hmacdope, manuel.nuno.melo, chrispfae, ooprathamm, MeetB7, BFedder, v-parmar, MoSchaeffler, jbarnoud, jandom, xhgchen, jaclark5, DrDomenicoMarson, AHMED-salah00 From b0493ef1454170c06066ca8c571434280390aec1 Mon Sep 17 00:00:00 2001 From: SophiaRuan Date: Thu, 23 Mar 2023 14:26:02 -0700 Subject: [PATCH 7/8] author and changelog --- package/AUTHORS | 1 + package/CHANGELOG | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/package/AUTHORS b/package/AUTHORS index bed47386e23..299887d1c82 100644 --- a/package/AUTHORS +++ b/package/AUTHORS @@ -211,6 +211,7 @@ Chronological list of authors - Xu Hong Chen - Domenico Marson - Ahmed Salah Ghoneim + - Xiaoxu Ruan External code ------------- diff --git a/package/CHANGELOG b/package/CHANGELOG index 93d7965f46e..1e9d14f5b0e 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -14,17 +14,9 @@ The rules for this file: ------------------------------------------------------------------------------ -03/20/23 SophiaRuan - -* 2.5.0 - -Changes - * Add progress bar to track the progress of _conclude() functions (_conclude_simple() and _conclude_fft()) in msd.py (PR #4072) - - ??/??/?? IAlibay, pgbarletta, mglagolev, hmacdope, manuel.nuno.melo, chrispfae, ooprathamm, MeetB7, BFedder, v-parmar, MoSchaeffler, jbarnoud, jandom, - xhgchen, jaclark5, DrDomenicoMarson, AHMED-salah00 + xhgchen, jaclark5, DrDomenicoMarson, AHMED-salah00, SophiaRuan * 2.5.0 Fixes @@ -54,6 +46,8 @@ Enhancements and SegmentGroup. (PR #3953) Changes + * Add progress bars to track the progress of _conclude() functions + (_conclude_simple() and _conclude_fft()) in msd.py (Issue #4070, PR #4072) * As per NEP29 the minimum supported NumPy version has been raised to 1.21 (note: in practice later versions of NumPy may be used depending on your architecture, operating system, or Python version) (PR #3983) From 26487730fcbe667f4923555109d81c0154c6f671 Mon Sep 17 00:00:00 2001 From: SophiaRuan <67963337+SophiaRuan@users.noreply.github.com> Date: Mon, 27 Mar 2023 15:05:13 -0700 Subject: [PATCH 8/8] Update package/CHANGELOG Co-authored-by: Hugo MacDermott-Opeskin --- package/CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/CHANGELOG b/package/CHANGELOG index 1e9d14f5b0e..cbedc97c9fc 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -13,7 +13,7 @@ The rules for this file: * release numbers follow "Semantic Versioning" http://semver.org ------------------------------------------------------------------------------ - + ??/??/?? IAlibay, pgbarletta, mglagolev, hmacdope, manuel.nuno.melo, chrispfae, ooprathamm, MeetB7, BFedder, v-parmar, MoSchaeffler, jbarnoud, jandom, xhgchen, jaclark5, DrDomenicoMarson, AHMED-salah00, SophiaRuan