-
Notifications
You must be signed in to change notification settings - Fork 667
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
Enabling of parallelization of analysis.atomicdistances.AtomicDistances
#4822
base: develop
Are you sure you want to change the base?
Changes from all commits
c79b7f0
1bd64bc
916a973
cbb3e66
16a0605
0b58a73
9836575
5d6ed62
fd8163a
2aad77d
102ff95
7b61370
fa52881
e7da740
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,7 @@ | |
|
||
import logging | ||
from .base import AnalysisBase | ||
from .results import Results | ||
|
||
logger = logging.getLogger("MDAnalysis.analysis.atomicdistances") | ||
|
||
|
@@ -145,6 +146,10 @@ class AtomicDistances(AnalysisBase): | |
|
||
|
||
.. versionadded:: 2.5.0 | ||
|
||
.. versionchanged:: 2.9.0 | ||
Enables parallelization through | ||
the use of `self.results.distances`. | ||
""" | ||
|
||
def __init__(self, ag1, ag2, pbc=True, **kwargs): | ||
|
@@ -163,14 +168,21 @@ def __init__(self, ag1, ag2, pbc=True, **kwargs): | |
self._ag1 = ag1 | ||
self._ag2 = ag2 | ||
self._pbc = pbc | ||
self.results = Results() | ||
|
||
def _prepare(self): | ||
# initialize NumPy array of frames x distances for results | ||
self.results = np.zeros((self.n_frames, self._ag1.atoms.n_atoms)) | ||
self.results.distances = np.zeros(( | ||
self.n_frames, self._ag1.atoms.n_atoms | ||
)) | ||
|
||
def _single_frame(self): | ||
# if PBCs considered, get box size | ||
box = self._ag1.dimensions if self._pbc else None | ||
self.results[self._frame_index] = calc_bonds(self._ag1.positions, | ||
self._ag2.positions, | ||
box) | ||
self.results.distances[self._frame_index] = calc_bonds( | ||
self._ag1.positions, self._ag2.positions, box | ||
) | ||
|
||
def _conclude(self): | ||
# adjust self.results to self.results.distances | ||
self.results = self.results.distances | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I'm just confused but it looks to me like the tests haven't actually changed yet (just formatting changes as far as I can tell?) and this just restored the original behavior of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, first I modified it to have the output would be As for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a hack! If this the way we want to go then you have to write more commentary to say what you're doing and why, with references to issue and a note that this needs to be changed for 3.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the docs above!!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... assuming a breaking change.