-
Notifications
You must be signed in to change notification settings - Fork 663
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
Waterdynamics.SurvivalProbability start/stop/step/tau_max #2525
Changes from 4 commits
d3a052b
5efc8cb
dd16e4b
9c9e453
8281522
6cb1f6c
3bd4fe9
31f1ea7
63680fe
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 |
---|---|---|
|
@@ -1237,28 +1237,17 @@ class SurvivalProbability(object): | |
|
||
|
||
.. versionadded:: 0.11.0 | ||
|
||
.. versionchanged:: 1.0.0 | ||
Removes support for the deprecated `t0`, `tf`, and `dtmax` keywords. | ||
These should instead be passed to :meth:`SurvivalProbability.run` as | ||
the `start`, `stop`, and `tau_max` keywords respectively. | ||
""" | ||
|
||
def __init__(self, universe, selection, t0=None, tf=None, dtmax=None, verbose=False): | ||
def __init__(self, universe, selection, verbose=False): | ||
self.universe = universe | ||
self.selection = selection | ||
self.verbose = verbose | ||
|
||
# backward compatibility | ||
self.start = self.stop = self.tau_max = None | ||
if t0 is not None: | ||
self.start = t0 | ||
warnings.warn("t0 is deprecated, use run(start=t0) instead", category=DeprecationWarning) | ||
|
||
if tf is not None: | ||
self.stop = tf | ||
warnings.warn("tf is deprecated, use run(stop=tf) instead", category=DeprecationWarning) | ||
|
||
if dtmax is not None: | ||
self.tau_max = dtmax | ||
warnings.warn("dtmax is deprecated, use run(tau_max=dtmax) instead", category=DeprecationWarning) | ||
|
||
def print(self, verbose, *args): | ||
if self.verbose: | ||
print(args) | ||
|
@@ -1316,55 +1305,63 @@ def _correct_intermittency(self, intermittency, selected_ids): | |
seen_frames_ago[atomid] = 0 | ||
|
||
|
||
def run(self, tau_max=20, start=0, stop=None, step=1, residues=False, intermittency=0, verbose=False): | ||
def run(self, tau_max=20, start=None, stop=None, step=None, residues=False, | ||
intermittency=0, verbose=False): | ||
""" | ||
Computes and returns the Survival Probability (SP) timeseries | ||
|
||
Parameters | ||
---------- | ||
start : int, optional | ||
Zero-based index of the first frame to be analysed | ||
Zero-based index of the first frame to be analysed, Default: None | ||
(first frame). | ||
stop : int, optional | ||
Zero-based index of the last frame to be analysed (inclusive) | ||
Zero-based index of the last frame to be analysed (exclusive), | ||
Default: None (last frame). | ||
step : int, optional | ||
Jump every `step`-th frame. This is compatible but independant of the taus used, and it is good to consider | ||
using the `step` equal to `tau_max` to remove the overlap. | ||
Note that `step` and `tau_max` work consistently with intermittency. | ||
Jump every `step`-th frame. This is compatible but independant of | ||
the taus used, and it is good to consider using the `step` equal | ||
to `tau_max` to remove the overlap. Note that `step` and `tau_max` | ||
work consistently with intermittency. Default: None | ||
(use every frame). | ||
tau_max : int, optional | ||
Survival probability is calculated for the range 1 <= `tau` <= `tau_max` | ||
Survival probability is calculated for the range | ||
1 <= `tau` <= `tau_max`. | ||
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. If stop is exclusive does this docstring need updating? 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. Not sure here. 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. Exactly, |
||
residues : Boolean, optional | ||
If true, the analysis will be carried out on the residues (.resids) rather than on atom (.ids). | ||
A single atom is sufficient to classify the residue as within the distance. | ||
If true, the analysis will be carried out on the residues | ||
(.resids) rather than on atom (.ids). A single atom is sufficient | ||
to classify the residue as within the distance. | ||
intermittency : int, optional | ||
The maximum number of consecutive frames for which an atom can leave but be counted as present if it returns | ||
at the next frame. An intermittency of `0` is equivalent to a continuous survival probability, which does | ||
not allow for the leaving and returning of atoms. For example, for `intermittency=2`, any given atom may | ||
leave a region of interest for up to two consecutive frames yet be treated as being present at all frames. | ||
The default is continuous (0). | ||
The maximum number of consecutive frames for which an atom can | ||
leave but be counted as present if it returns at the next frame. | ||
An intermittency of `0` is equivalent to a continuous survival | ||
probability, which does not allow for the leaving and returning of | ||
atoms. For example, for `intermittency=2`, any given atom may leave | ||
a region of interest for up to two consecutive frames yet be | ||
treated as being present at all frames. The default is continuous | ||
(0). | ||
verbose : Boolean, optional | ||
Print the progress to the console | ||
Print the progress to the console. | ||
|
||
Returns | ||
------- | ||
tau_timeseries : list | ||
tau from 1 to `tau_max`. Saved in the field tau_timeseries. | ||
sp_timeseries : list | ||
survival probability for each value of `tau`. Saved in the field sp_timeseries. | ||
""" | ||
survival probability for each value of `tau`. Saved in the field | ||
sp_timeseries. | ||
|
||
# backward compatibility (and priority) | ||
start = self.start if self.start is not None else start | ||
stop = self.stop if self.stop is not None else stop | ||
tau_max = self.tau_max if self.tau_max is not None else tau_max | ||
|
||
# sanity checks | ||
if stop is not None and stop >= len(self.universe.trajectory): | ||
raise ValueError("\"stop\" must be smaller than the number of frames in the trajectory.") | ||
.. versionchanged:: 1.0.0 | ||
To math other analysis methods, the `stop` keyword is now exclusive | ||
rather than inclusive. | ||
""" | ||
|
||
if stop is None: | ||
stop = len(self.universe.trajectory) | ||
else: | ||
stop = stop + 1 | ||
start, stop, step = self.universe.trajectory.check_slice_indices( | ||
start, | ||
stop, | ||
step | ||
) | ||
|
||
if tau_max > (stop - start): | ||
raise ValueError("Too few frames selected for given tau_max.") | ||
|
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.
There is no longer backward compatibility warnings? why?
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.
@alejob by this do you mean the removal of
t0
,tf
, anddtmax
? These have been slated for deprecation for a long time. As part of the upcoming 1.0.0 release, we are aiming to remove all historical deprecated code.