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

Deprecate guess_bonds and bond guessing kwargs in Universe #4757

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

lilyminium
Copy link
Member

@lilyminium lilyminium commented Oct 20, 2024

Fixes #4756

Changes made in this Pull Request:

  • Adds deprecation warning to bond keywords

PR Checklist

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

Developers certificate of origin


📚 Documentation preview 📚: https://mdanalysis--4757.org.readthedocs.build/en/4757/

@pep8speaks
Copy link

pep8speaks commented Oct 20, 2024

Hello @lilyminium! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 296:1: W293 blank line contains whitespace
Line 453:80: E501 line too long (81 > 79 characters)

Comment last updated at 2024-10-25 04:43:42 UTC

Copy link

codecov bot commented Oct 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.62%. Comparing base (d2729f7) to head (78056eb).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4757      +/-   ##
===========================================
- Coverage    93.65%   93.62%   -0.03%     
===========================================
  Files          175      187      +12     
  Lines        21565    22632    +1067     
  Branches      3023     3023              
===========================================
+ Hits         20196    21190     +994     
- Misses         925      998      +73     
  Partials       444      444              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

I only have minor documentation update requests, otherwise looks good.

Comment on lines 115 to 116
* The `guess_bonds`, `vdwradii`, `fudge_factor`, and `lower_bound` kwargs
are deprecated for Universe creation. (Issue #4756, PR #4757)
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps state what should be used instead? Such as "use Universe.to_guess(...) instead".

"Bond guessing through the `guess_bonds` keyword is deprecated"
" and will be removed in MDAnalysis 3.0. "
"Instead, pass 'bonds', 'angles', and 'dihedrals' to "
"the `to_guess` keyword in Universe for guessing these. "
Copy link
Member

Choose a reason for hiding this comment

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

add a

.. deprecated:: 2.8.0
   Will be removed in 3.0.0. Pass pass into Context creation or Universe.guess_TopologyAttrs.

under each of the deprecated keyword args fudge_factor, vdwradii, lower_bound. Link to Context docs and guess_TopologyAttrs.

Copy link
Member

Choose a reason for hiding this comment

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

Be specific about where the kwargs should go, either Context or guess_TopologyAttrs.

Copy link
Contributor

Choose a reason for hiding this comment

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

A few extra thoughts:

  1. The order of the attributes in ['bonds', 'angles', 'dihedrals'] is important because later attributes depend on the earlier ones. We may want to implement a function that automatically reorders the guessing sequence to ensure proper dependencies are respected?
    2. The correct usage should be force_guess=['bonds', 'angles', 'dihedrals'] instead of to_guess. Refer to Unclear Error When Using to_guess=['bonds'] with Existing Bonds in Topology #4759

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the connectivity topology attrs do have dependencies built in, happily -- there's an existing test that guesses angles without bonds (

def test_guess_angles_with_no_bonds():
"Test guessing angles for atoms with no bonds"
" information without adding bonds to universe "
u = mda.Universe(datafiles.two_water_gro)
u.guess_TopologyAttrs(to_guess=['angles'])
assert hasattr(u, 'angles')
assert not hasattr(u, 'bonds')
). I think that means we don't need to specify the dependencies in order. Hmm... I should add a test that guessing angles/dihedrals does respect the vdwradii, etc. keywords used to control bond guessing though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in #4761

@@ -407,6 +407,17 @@ def __init__(self, topology=None, *coordinates, all_coordinates=False,
self._trajectory.add_transformations(*transformations)

if guess_bonds:
warnings.warn(
"Bond guessing through the `guess_bonds` keyword is deprecated"
Copy link
Member

Choose a reason for hiding this comment

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

Add a deprecation doc string under guess_bonds with this information so that it shows up in the docs.

"Bond guessing through the `guess_bonds` keyword is deprecated"
" and will be removed in MDAnalysis 3.0. "
"Instead, pass 'bonds', 'angles', and 'dihedrals' to "
"the `to_guess` keyword in Universe for guessing these. "
Copy link
Contributor

Choose a reason for hiding this comment

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

A few extra thoughts:

  1. The order of the attributes in ['bonds', 'angles', 'dihedrals'] is important because later attributes depend on the earlier ones. We may want to implement a function that automatically reorders the guessing sequence to ensure proper dependencies are respected?
    2. The correct usage should be force_guess=['bonds', 'angles', 'dihedrals'] instead of to_guess. Refer to Unclear Error When Using to_guess=['bonds'] with Existing Bonds in Topology #4759

@IAlibay IAlibay added this to the Release 2.8.0 milestone Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bond guessing double specified in Universe.__init__
5 participants