-
Notifications
You must be signed in to change notification settings - Fork 104
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
Improve Python leapfrog integration performance #690
Conversation
Hi @jobovy, here are the changes discussed in #365. As far as I can tell there is just one small change needed for the tests; passing Though not necessarily related to the leapfrog integration, I also move the non-axi check from On a related note; I also looked at adding a Let me know if there's anything I've missed. EDIT: Oops, a couple of extra commits for some things that I missed. I have edited this comment to match. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #690 +/- ##
==========================================
- Coverage 99.91% 93.29% -6.62%
==========================================
Files 200 200
Lines 29400 29413 +13
Branches 564 564
==========================================
- Hits 29374 27441 -1933
- Misses 26 1972 +1946 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Thanks @jamesgrimmett, this looks great! A few comments:
|
Hi @jobovy, I've made the change that you suggested to resolve the actionAngle test failures - that works, thanks!
I made this change, but in the process I have now added an I have also adjusted the Hope that's all OK, it does increase the scope of this change a bit, so just let me know if you had something else in mind. |
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.
Thanks for these updates! I like the addition of the isDissipative
attribute, but I've left a few minor comments on the implementation that I think should be easy to address. There is also now a new slight issue that there are five lines in verticalPotential.py
that are not covered by the tests:
https://app.codecov.io/gh/jobovy/galpy/pull/690/blob/galpy/potential/verticalPotential.py
These used to be covered, but aren't anymore because the new code in _isDissipative
now raises the PotentialError
. Just in case future changes to _isDissipative
could let these bad inputs through again, I think it's good to just keep the checks in verticalPotential.py
, so perhaps we should just label them when # pragma: no cover
so they are excluded from the coverage calculation (because they should never be hit). You can just put the # pragma: no cover
after the relevant colon (e.g.. after except:
or after else:
.
Once this is done and the coverage is back to what it was, I think this will be good to be merged!
I don't know how familiar you are with rebasing, but if you are, it could be good to clean up the commit history a bit, by combining the commits that update the leapfrog implementation, the commits to HISTORY.txt
and perhaps combining some other commits as well. I try to keep the commit history relatively clean these days and normally I would just squash a PR into a single commit to do that, but in this case it would be good to separate the PR into a few commits. But if you're not familiar with rebasing, I can also clean the commit history up a bit before merging.
Thanks for your comments - I've resolved most, but just had a couple of questions for the remaining two. I'm happy to do a rebase once I finish up the last couple of changes. I'll try to group everything into a few commits, but of course feel free to re-rebase if you can see a cleaner way to group the changes. |
ce850ee
to
ea860f3
Compare
…implementation add time increment after final kick and drift Combine the drifts for more efficient computation in Python leapfrog implementation
… dissipative checks from internal to public evaluation functions shift the non-axi check from internal to public evaluatePotentials function update error type returned during test add a _isNonAxi check to estimateDeltaStaeckel after removal from internal force calculation functions add an isDissipative attribute to potential/force classes to simplify _isDissipative check shift the non-axi check from internal to public evaluate functions for planarPotentials exclude some potential checks from code coverage add tests for raising potential error from _isNonAxi Use isDissipative attribute rather than checking with function Co-authored-by: Jo Bovy <jo.bovy@gmail.com> remove extraneous isDissipative attribute setting in the Force class Co-authored-by: Jo Bovy <jo.bovy@gmail.com> expand try/except block in isDissipative function Add an isDissipative attribute to potentials and move the non-axi and dissipative checks from internal to public evaluation functions use isDissipative attribute rather than isinstance checks move setting isDissipative attribute from planarForce to planarPotential use isDissipative attribute rather than isinstance checks Add an isDissipative attribute to potentials and move the non-axi and dissipative checks from internal to public evaluation functions
remove comment from HISTORY.txt update HISTORY.txt with recent changes
ea860f3
to
2854f68
Compare
Hi @jamesgrimmett, Thanks for these final tweaks and for the clean rebase. I made some final very minor tweaks to |
See discussions in #365
This change aligns the Python implementation of the leapfrog integrator with the C code by combining the drift calculations to reduce computations in the inner integration loop.
Also, the checks for non-axisymmetric and dissipative Potentials are moved from the internal (e.g., _evaluateRforces) to public (e.g., evaluateRforces) methods in order to avoid calling the checks at every loop iteration.
Provides a ~50% reduction in computation time.
Profiling
main
using this scriptProfiling this branch;