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

Fixes PM issues (jlab and non-AnalysisBase) #2310

Merged
merged 4 commits into from
Aug 7, 2019

Conversation

IAlibay
Copy link
Member

@IAlibay IAlibay commented Aug 2, 2019

Fixes #2084 and #2078 (partly)

Changes made in this Pull Request:

  • So nearly a year late on this one. Here are a couple of changes to some of the ProgressMeter calls that caused issues with Jupyter Lab (note that even without these changes the latest version of Jupyter Lab doesn't cause what was seen in ProgressMeter doesn't work in jupyter lab #2078, although the extra carriage returns aren't necessary). I realise that as per replace custom ProgressMeter with tqdm #928 (comment) ProgressMeter is probably going to give way to tdqm but I thought I might as well push these changes whilst tdqm isn't implemented.

  • This PR also updates the ProgressMeter behaviour of some of the currently non-AnalysisBase methods (namely density_from_Universe, HydrogenBondAutoCorrel, and helanal). Again this is probably not necessary in the long run (considering for example update analysis.base.AnalysisBase to conform to API #1463 (comment)) if the aim is to add everything to AnalysisBase. However I thought it probably was worth adding it in as a temporary fix.

  • This PR also adds a couple of warnings & exceptions to helanal that weren't being checked for when providing the begin and finish arguments.

  • This PR does not provide any ProgressMeter changes to hbond_analysis or wbridge_analysis since they are currently being migrated to AnalysisBase (Hbond analysis #2237 and Move the water bridge analysis to the new analysis class #2087).

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

Many thanks, I am happy to get this in, including your cleanup/testing in helanal.

One minor request (see comment): replace the custom FinishTimeException with a simple ValueError. I don't think there's a need for introducing another exception, is there?

I'll wait for Travis to come back with tests passing. Feel free to ping me when I should look again.

# finish occurs before begin time
msg = ("The input finish time ({0} ps) precedes the input begin "
"time ({1} ps)".format(finish, begin))
raise FinishTimeException(msg)
Copy link
Member

Choose a reason for hiding this comment

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

While you're at it, could you please get rid of FinishTimeException and just raise a ValueError (because the user provided a wrong value). Makes more sense...

with tmpdir.as_cwd():
with pytest.raises(FinishTimeException):
MDAnalysis.analysis.helanal.helanal_trajectory(
u, selection="name CA", finish=5
)

with tmpdir.as_cwd():
with pytest.raises(FinishTimeException):
Copy link
Member

Choose a reason for hiding this comment

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

Let's use a ValueError, more in line with standard Python usage

@orbeckst orbeckst self-assigned this Aug 2, 2019
@codecov
Copy link

codecov bot commented Aug 2, 2019

Codecov Report

Merging #2310 into develop will increase coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2310      +/-   ##
===========================================
+ Coverage    89.59%   89.65%   +0.06%     
===========================================
  Files          157      157              
  Lines        19525    19530       +5     
  Branches      2803     2802       -1     
===========================================
+ Hits         17493    17510      +17     
+ Misses        1435     1427       -8     
+ Partials       597      593       -4
Impacted Files Coverage Δ
package/MDAnalysis/analysis/pca.py 87.77% <ø> (ø) ⬆️
package/MDAnalysis/analysis/rms.py 90.66% <ø> (ø) ⬆️
package/MDAnalysis/analysis/helanal.py 88.03% <100%> (+2.83%) ⬆️
package/MDAnalysis/analysis/density.py 64.94% <100%> (ø) ⬆️
...age/MDAnalysis/analysis/hbonds/hbond_autocorrel.py 87.8% <100%> (ø) ⬆️
package/MDAnalysis/topology/TOPParser.py 100% <0%> (ø) ⬆️
package/MDAnalysis/lib/util.py 88.47% <0%> (+0.29%) ⬆️
package/MDAnalysis/coordinates/TRJ.py 91.51% <0%> (+0.9%) ⬆️

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 7449a38...74a4426. Read the comment docs.

@IAlibay
Copy link
Member Author

IAlibay commented Aug 2, 2019

Thanks for the review @orbeckst

FinishTimeException was just used because it was the existing custom exception that seems to have been historically used in the helix analysis code. As per your suggestion, I have now changed everything to ValueError in 05849eb.

Since this was the only part of the MDAnalysis code that used this custom exception, I went ahead and removed it completely from exceptions.py and __init__.py, hopefully that's ok?

@orbeckst
Copy link
Member

orbeckst commented Aug 2, 2019

Yes, thank you, excellent!

@orbeckst orbeckst merged commit 165d2e4 into MDAnalysis:develop Aug 7, 2019
@orbeckst
Copy link
Member

orbeckst commented Aug 7, 2019

Thanks @IAlibay , sorry, took me a while to come back to.

@IAlibay IAlibay deleted the PMFix branch August 7, 2019 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected behaviour of ProgressMeter in some analysis methods
3 participants