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

Waterdynamics.SurvivalProbability start/stop/step/tau_max #2525

Merged

Conversation

IAlibay
Copy link
Member

@IAlibay IAlibay commented Feb 10, 2020

Fixes #2524

Changes made in this Pull Request:

  • Removes the t0, tf, and dtmax keywords from the :class:Waterdynamics.SurvivalProbability constructor.
  • Makes the stop keyword for :meth:WaterDynamics.SurvivalProbability.run exclusive rather than inclusive.

PR Checklist

  • Tests? (using existing tests, just ammending stop to be 1 higher).
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

@codecov
Copy link

codecov bot commented Feb 10, 2020

Codecov Report

Merging #2525 into develop will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2525      +/-   ##
===========================================
+ Coverage    91.14%   91.19%   +0.04%     
===========================================
  Files          174      174              
  Lines        23717    23700      -17     
  Branches      3104     3099       -5     
===========================================
- Hits         21618    21614       -4     
+ Misses        1480     1472       -8     
+ Partials       619      614       -5     
Impacted Files Coverage Δ
package/MDAnalysis/analysis/waterdynamics.py 93.93% <100.00%> (+3.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 41ebfdf...63680fe. Read the comment docs.

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`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If stop is exclusive does this docstring need updating?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure here. tau_max should be independent of stop, i.e. previously the case was that stop was set in the code to be stop+1. The changes done here only change it so that stop=stop, tau and tau_max's behaviour shouldn't be affected (if that makes sense).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, tau_max is independent of stop.

Copy link
Member

@richardjgowers richardjgowers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the exclusive/inclusive change line this class up with the others?

@IAlibay
Copy link
Member Author

IAlibay commented Feb 28, 2020

Does the exclusive/inclusive change line this class up with the others?

@richardjgowers I think I have pretty much failed to understand what you meant from your review 😅 Any chance you could add some more info?

@richardjgowers
Copy link
Member

richardjgowers commented Feb 28, 2020 via email

@IAlibay
Copy link
Member Author

IAlibay commented Mar 1, 2020

You made stop exclusive (or inclusive) when it was the other way around. Is it now like other classes?

@richardjgowers Yeah, so as per #2505 (review) the idea in making it exclusive was to align it with the AnalysisBase's exclusive stop behaviour:

for i, ts in enumerate(
self._trajectory[self.start:self.stop:self.step]):

With regards to the other waterdynamics classes, unfortunately I'm not sure. I'm having a bit of a hard time working out how HydrogenBondLifetimes's tf keyword is working, but it looks like it's exclusive?

For WaterOrientationalRelaxation, this line seems to indicate that self.tf (passed to totalFrames) is exclusive (similar thing for MeanSquareDisplacement):

for j in range(totalFrames // dt - 1):

@orbeckst orbeckst requested a review from alejob March 13, 2020 00:26
@orbeckst
Copy link
Member

@alejob could you please also review this PR on WaterDynamics?

There were a few questions #2525 (comment) and maybe you as one of the authors can answer them.

Thanks!

@alejob
Copy link
Member

alejob commented Mar 16, 2020

Ok, let me check this and I'll answer in a couple of days. I didn't realize all the current changes.

@IAlibay
Copy link
Member Author

IAlibay commented Mar 29, 2020

Ok, let me check this and I'll answer in a couple of days. I didn't realize all the current changes.

Just re-pinging @alejob as a reminder for review. I do realise things are a little bit (that's probably an understatement) chaotic for everyone, so no worries if you don't have time to review this.

@alejob
Copy link
Member

alejob commented Apr 3, 2020

Hey there!
All the module was written with inclusion in mind, regarding the tf parameter.

With regards to the other waterdynamics classes, unfortunately I'm not sure. I'm having a bit of a hard time working out how HydrogenBondLifetimes's tf keyword is working, but it looks like it's exclusive?

It is also inclusive, in the code it is define as

but later I use this in this way

tf is a value fill by self.tf.

For WaterOrientationalRelaxation, this line seems to indicate that self.tf (passed to totalFrames) is exclusive (similar thing for MeanSquareDisplacement):

The -1 is because the list start in zero, so if there is not -1, there will be a "list index out of bound".

for j in range(totalFrames // dt - 1):

I hava a question about this PR, this is only for make it consistent with the AnalysisBase? I'm pretty sure I lost a discussion about this, but does this PR improve something in the usability of this class? and also, If I want to obtain the same results that this module delivers, with the new implementation I should add an unit to the tf value? ex: If before this PR I wanted to calculate something until the frame 1000, now should I write 1001?

@IAlibay
Copy link
Member Author

IAlibay commented Apr 8, 2020

Thanks for having a look through @alejob

It seems like I've completely failed to understand the behaviour of tf for most of these classes, I'll have a longer look at this.

I hava a question about this PR, this is only for make it consistent with the AnalysisBase?

So there are two aims to this PR.

  1. Probably the most important thing re: v1.0 here is to remove the deprecated t0, tf, and dtmax keywords from the :Waterdynamics.SurvivalProbability.
  2. As pointed out by @orbeckst (Remove start/stop/step from AnalysisBase kwargs #2505 (review)) there is also a descrepancy between how Waterdynamics treats stop relative to how AnalysisBase does. So this PR aims to at least fix this for SurvivalProbability (although the question was raised as to whether or not this should be done for the whole of WaterDynamics).

I'm pretty sure I lost a discussion about this, but does this PR improve something in the usability of this class?

Whilst the current behaviour is documented in SurvivalProbability, one could see, especially considering my above failure to understand tf across most of the classes, how a user error could come up here. So the view here is that making things similar to AnalysisBase would avoid these kinds of errors / allow for a more consistent API.

and also, If I want to obtain the same results that this module delivers, with the new implementation I should add an unit to the tf value? ex: If before this PR I wanted to calculate something until the frame 1000, now should I write 1001?

Indeed, assuming one had frames ranging from 0 to 1000, then if passed explicitly stop should be equal to 1001 (or higher) to cover the full range of frames. As far as I am aware, this is the current way in which AnalysisBase works.

@orbeckst
Copy link
Member

@IAlibay, I just merged PR #2256 which changed waterdynamics. Can you do resolve the conflicts and have a look again?

@orbeckst orbeckst added this to the 1.0 milestone May 15, 2020
@orbeckst
Copy link
Member

This looks mostly done (bringing WaterAnalysis in-line with the other analysis classes) although the following seems needed:

  • resolving conflicts (might not be trivial so @IAlibay should do it)
  • @richardjgowers 's blocking review – I think @IAlibay answered his question (now all exclusive, in line with AnalysisBase use) but please check that you're satisfied
  • @alejob can you please do a formal review of the changes with an "approve" or "changes requested"?
  • I'll be happy to do a review after @alejob – but I don't know the code as well as the original author so I'll mostly follow @alejob 's lead.

I added it to the 1.0 milestone so let's get this done.

@IAlibay
Copy link
Member Author

IAlibay commented May 15, 2020

Sorry about the delay here @orbeckst, I've got a slot in my calendar specifically to look at this tomorrow :)

A thought, do we want to extend this beyond survival probability to make stop exclusive across all of waterdynamics?

@orbeckst
Copy link
Member

A thought, do we want to extend this beyond survival probability to make stop exclusive across all of waterdynamics?

That would be great – even if we don't have everything AnalysisBase-based yet, having a consistent interface is necessary. And with semantic versioning, backwards-incompatible changes in the API are very annoying because you need to bump the major version. Changing the meaning of the stop argument is such a major API change because it will lead to wrong results between different versions. I don't think anyone wants to go to MDA 2.0 just in order to update the arguments in waterdynamics...

@orbeckst
Copy link
Member

Sorry about the delay here

Oh, forgot: please do not apologize!!!!! You're doing an awful lot of work here, thank you, thank you!

I see it as my job to occasionally check on PRs and help shepherd them to completion so that all the work that has already gone into them also counts. Sometimes one just has to clarify what needs doing.

@orbeckst
Copy link
Member

A thought, do we want to extend this beyond survival probability to make stop exclusive across all of waterdynamics?

I would open a new PR, though, just to get this one done. It can then serve as a blueprint for the rest.

As we're preaching to our GSoC students: many small PRs are better than one big one ;-).

@IAlibay
Copy link
Member Author

IAlibay commented May 27, 2020

The conflicts should now be solved. Pinging @richardjgowers and @alejob for review.

@orbeckst
Copy link
Member

@alejob your review is important here. Do you have an idea when you might be able to do it? Thanks!

@alejob
Copy link
Member

alejob commented May 29, 2020 via email

Copy link
Member

@alejob alejob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that is necessary to have a module that is compatible with the AnalysisBase, so I'm very happy with the general idea.

In the other side I don't see changes on the examples of documentation (or a comment), please change that, because it will be the only updated class and that could be confusing.



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,
Copy link
Member

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?

Copy link
Member Author

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, and dtmax? 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.

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`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, tau_max is independent of stop.

IAlibay added 2 commits May 30, 2020 08:17
Adds more documentation to detail that :class:`SurvivalProbability` now has an exclusive behaviour unike the other :mod:`MDAnalysis.analysis.waterdynamics` classes.
@IAlibay
Copy link
Member Author

IAlibay commented May 30, 2020

In the other side I don't see changes on the examples of documentation (or a comment), please change that, because it will be the only updated class and that could be confusing.

Thanks for the review @alejob. I have included documentation (beyond what was already in :meth:SurvivalProbability.run. Let me know if this is what you had in mind & if you think it needs changes.

Copy link
Member

@alejob alejob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@orbeckst
Copy link
Member

Ping @richardjgowers for final approval?

@richardjgowers richardjgowers merged commit 0911ff3 into MDAnalysis:develop Jun 1, 2020
@fiona-naughton fiona-naughton added maintainability Component-Analysis deprecation Deprecated functionality to give advance warning for API changes. labels Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component-Analysis deprecation Deprecated functionality to give advance warning for API changes. maintainability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Align behaviour of waterdynamics.SurvivalProbability with other analysis methods
5 participants