Skip to content

Commit

Permalink
Merge branch 'develop' into parallelization_polymer
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishy7777 authored Jan 6, 2025
2 parents dc6e903 + 536a390 commit b7328ba
Show file tree
Hide file tree
Showing 157 changed files with 12,468 additions and 7,429 deletions.
1 change: 1 addition & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Fixes

Enhancements
* Enables parallelization for analysis.polymer.PersistenceLength (Issue #4671)
* Addition of 'water' token for water selection (Issue #4839)
* Enables parallelization for analysis.density.DensityAnalysis (Issue #4677, PR #4729)
* Enables parallelization for analysis.contacts.Contacts (Issue #4660)
* Enable parallelization for analysis.nucleicacids.NucPairDist (Issue #4670)
Expand Down
54 changes: 27 additions & 27 deletions package/MDAnalysis/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,31 @@
#

__all__ = [
'align',
'backends',
'base',
'contacts',
'density',
'distances',
'diffusionmap',
'dihedrals',
'distances',
'dielectric',
'gnm',
'hbonds',
'helix_analysis',
'hole2',
'hydrogenbonds',
'leaflet',
'lineardensity',
'msd',
'nuclinfo',
'nucleicacids',
'polymer',
'pca',
'psa',
'rdf',
'results',
'rms',
'waterdynamics',
"align",
"backends",
"base",
"contacts",
"density",
"distances",
"diffusionmap",
"dihedrals",
"distances",
"dielectric",
"gnm",
"hbonds",
"helix_analysis",
"hole2",
"hydrogenbonds",
"leaflet",
"lineardensity",
"msd",
"nuclinfo",
"nucleicacids",
"polymer",
"pca",
"psa",
"rdf",
"results",
"rms",
"waterdynamics",
]
27 changes: 16 additions & 11 deletions package/MDAnalysis/analysis/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
-------
"""

import warnings
from typing import Callable
from MDAnalysis.lib.util import is_installed
Expand Down Expand Up @@ -102,8 +103,9 @@ def _get_checks(self):
checked during ``_validate()`` run
"""
return {
isinstance(self.n_workers, int) and self.n_workers > 0:
f"n_workers should be positive integer, got {self.n_workers=}",
isinstance(self.n_workers, int)
and self.n_workers
> 0: f"n_workers should be positive integer, got {self.n_workers=}",
}

def _get_warnings(self):
Expand Down Expand Up @@ -183,8 +185,8 @@ def _get_warnings(self):
checked during ``_validate()`` run
"""
return {
self.n_workers == 1:
"n_workers is ignored when executing with backend='serial'"
self.n_workers
== 1: "n_workers is ignored when executing with backend='serial'"
}

def apply(self, func: Callable, computations: list) -> list:
Expand Down Expand Up @@ -307,10 +309,12 @@ def apply(self, func: Callable, computations: list) -> list:
import dask

computations = [delayed(func)(task) for task in computations]
results = dask.compute(computations,
scheduler="processes",
chunksize=1,
num_workers=self.n_workers)[0]
results = dask.compute(
computations,
scheduler="processes",
chunksize=1,
num_workers=self.n_workers,
)[0]
return results

def _get_checks(self):
Expand All @@ -326,8 +330,9 @@ def _get_checks(self):
"""
base_checks = super()._get_checks()
checks = {
is_installed("dask"):
("module 'dask' is missing. Please install 'dask': "
"https://docs.dask.org/en/stable/install.html")
is_installed("dask"): (
"module 'dask' is missing. Please install 'dask': "
"https://docs.dask.org/en/stable/install.html"
)
}
return base_checks | checks
Loading

0 comments on commit b7328ba

Please sign in to comment.