Skip to content

Commit

Permalink
mark analysis.pca.PCA as not parallelizable (#4684)
Browse files Browse the repository at this point in the history
- fix #4680
- PCA explicitly marked as not parallelizable (at least not with
  simple split-apply-combine)
- add tests
- update CHANGELOG
  • Loading branch information
orbeckst authored Aug 26, 2024
1 parent 94b1b79 commit d73995a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The rules for this file:
??/??/?? IAlibay, HeetVekariya, marinegor, lilyminium, RMeli,
ljwoods2, aditya292002, pstaerk, PicoCentauri, BFedder,
tyler.je.reddy, SampurnaM, leonwehrhan, kainszs, orionarcher,
yuxuanzhuang, PythonFZ, laksh-krishna-sharma
yuxuanzhuang, PythonFZ, laksh-krishna-sharma, orbeckst

* 2.8.0

Expand Down Expand Up @@ -55,6 +55,7 @@ Fixes
Enhancements
* Introduce parallelization API to `AnalysisBase` and to `analysis.rms.RMSD` class
(Issue #4158, PR #4304)
* explicitly mark `analysis.pca.PCA` as not parallelizable (Issue #4680)
* Improve error message for `AtomGroup.unwrap()` when bonds are not present.(Issue #4436, PR #4642)
* Add `analysis.DSSP` module for protein secondary structure assignment, based on [pydssp](https://github.com/ShintaroMinami/PyDSSP)
* Added a tqdm progress bar for `MDAnalysis.analysis.pca.PCA.transform()`
Expand Down
3 changes: 2 additions & 1 deletion package/MDAnalysis/analysis/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class PCA(AnalysisBase):
generates the principal components of the backbone of the atomgroup and
then transforms those atomgroup coordinates by the direction of those
variances. Please refer to the :ref:`PCA-tutorial` for more detailed
instructions. When using mean selections, the first frame of the selected
instructions. When using mean selections, the first frame of the selected
trajectory slice is used as a reference.
Parameters
Expand Down Expand Up @@ -239,6 +239,7 @@ class PCA(AnalysisBase):
incorrectly handle cases where the ``frame`` argument
was passed.
"""
_analysis_algorithm_is_parallelizable = False

def __init__(self, universe, select='all', align=False, mean=None,
n_components=None, **kwargs):
Expand Down
21 changes: 21 additions & 0 deletions testsuite/MDAnalysisTests/analysis/test_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import numpy as np
import MDAnalysis as mda
from MDAnalysis.analysis import align
import MDAnalysis.analysis.pca
from MDAnalysis.analysis.pca import (PCA, cosine_content,
rmsip, cumulative_overlap)

Expand Down Expand Up @@ -384,3 +385,23 @@ def test_pca_attr_warning(u, attr):
wmsg = f"The `{attr}` attribute was deprecated in MDAnalysis 2.0.0"
with pytest.warns(DeprecationWarning, match=wmsg):
getattr(pca, attr) is pca.results[attr]

@pytest.mark.parametrize(
"classname,is_parallelizable",
[
(MDAnalysis.analysis.pca.PCA, False),
]
)
def test_class_is_parallelizable(classname, is_parallelizable):
assert classname._analysis_algorithm_is_parallelizable == is_parallelizable


@pytest.mark.parametrize(
"classname,backends",
[
(MDAnalysis.analysis.pca.PCA, ('serial',)),
]
)
def test_supported_backends(classname, backends):
assert classname.get_supported_backends() == backends

0 comments on commit d73995a

Please sign in to comment.