Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCA not showing progress bar on mean structure calculation #3773

Closed
rsexton2 opened this issue Aug 5, 2022 · 6 comments · Fixed by #4531
Closed

PCA not showing progress bar on mean structure calculation #3773

rsexton2 opened this issue Aug 5, 2022 · 6 comments · Fixed by #4531

Comments

@rsexton2
Copy link
Contributor

rsexton2 commented Aug 5, 2022

Expected behavior

Progress bar should be shown when computing mean structure for PCA when verbose=True.

Actual behavior

Progress bar is shown for PCA calculation but not for mean structure calculation.

Code to reproduce the behavior

import MDAnalysis as mda
import MDAnalysis.analysis.pca as pca
from MDAnalysis.tests.datafiles import PSF, DCD
u = mda.Universe(PSF, DCD)
PSF_pca = pca.PCA(u, select='backbone')
PSF_pca.run(verbose=True)

Current version of MDAnalysis

  • Which version are you using? (run python -c "import MDAnalysis as mda; print(mda.__version__)") 2.3.0-dev0
  • Which version of Python (python -V)? 3.10.4
  • Which operating system? Ubuntu 20.04
@rsexton2
Copy link
Contributor Author

rsexton2 commented Aug 5, 2022

Progress bar is shown for mean structure calculation when verbose=True is passed to the class constructor

PSF_pca = pca.PCA(u, select='backbone', verbose=True)

@rsexton2
Copy link
Contributor Author

rsexton2 commented Aug 5, 2022

It would also be convenient for PCA.transform() to take a verbose flag because it takes a long time to complete

@SampurnaM
Copy link
Contributor

Hi @rsexton2 and @orbeckst ,
I took the liberty of creating a small PR implementing the requested fix : please let me know if this helps and if it's correct?

This is also my first proper open-source contribution, very happy to edit/mend/read more things!

Sampurna

@SampurnaM
Copy link
Contributor

As per comments in #4531 :)

Screenshots attached to show how the progress bar looks now, for PCA.transform():

Current version of MDAnalysis

Which version are you using? (run python -c "import MDAnalysis as mda; print(mda.version)") 2.8.0-dev0
Which version of Python (python -V)? Python 3.12.2
Which operating system? Ubuntu 20.04.6 LTS

Code to reproduce the behavior

import MDAnalysis as mda
import MDAnalysis.analysis.pca as pca
from MDAnalysis.tests.datafiles import PSF, DCD
u = mda.Universe(PSF, DCD)
PSF_pca = pca.PCA(u, select='backbone')
PSF_pca.run(verbose=True)
n_pcs = np.where(PSF_pca.results.cumulated_variance > 0.95)[0][0]
atomgroup = u.select_atoms('backbone')
pca_space = PSF_pca.transform(atomgroup, n_components=n_pcs, verbose=True)

image

Testing the function logic in JupyterLab for the older MDA 2.7.0 version, in a different environment

Current version of MDAnalysis

Which version are you using? (run python -c "import MDAnalysis as mda; print(mda.version)") 2.7.0
Which version of Python (python -V)? Python 3.10.8
Which operating system? Ubuntu 20.04.6 LTS

image

@orbeckst
Copy link
Member

For completeness, can you also demonstrate

pca_space = PSF_pca.transform(atomgroup, n_components=n_pcs, verbose=True)

in a notebook, please?

@SampurnaM
Copy link
Contributor

SampurnaM commented Mar 27, 2024

Here it is.

Note:

JupyterLab version: 4.1.5
For using tqdm , I had to install ipywidgets in mdanalysis-dev environment and jupyterlab-widgets in the base
!conda install -n base -c conda-forge jupyterlab_widgets
!conda install -n mdanalysis-dev -c conda-forge ipywidgets

image

IAlibay pushed a commit that referenced this issue Mar 28, 2024
Fixes #3773

Adds tqdm progress bar to  the `pca.transform` method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants