Skip to content

Conversation

@Agarwalchetan
Copy link

@Agarwalchetan Agarwalchetan commented Dec 15, 2025

Description

This PR adds comprehensive type hints to the MDAnalysis.analysis.rms module as part of the ongoing effort to improve type safety, code documentation, and developer experience in MDAnalysis.

Changes Made

New Imports

  • Added typing imports: Optional, Union, List, Dict, Any, Sequence, Tuple, TYPE_CHECKING
  • Added numpy.typing.NDArray for array type hints
  • Used TYPE_CHECKING guard for AtomGroup and Universe imports to avoid circular import issues at runtime

Function rmsd()

  • Added type annotations for all parameters:
    • a: NDArray, b: NDArray - coordinate arrays
    • weights: Optional[NDArray] - optional weight array
    • center: bool, superposition: bool - boolean flags
  • Added return type annotation: -> float

Function process_selection()

  • Added type hint for select parameter: Union[str, Tuple[str, str], Dict[str, str]]
  • Added return type annotation: -> Dict[str, Any]

Class RMSD

  • Added class-level type annotations for instance attributes:
    • atomgroup, reference, groupselections, weights
    • weights_groupselections, tol_mass, ref_frame
  • Added type hints to __init__() parameters including complex union types
  • Added return type annotations to _prepare() and _single_frame() methods: -> None
  • Added type assertions to help mypy with type inference in complex control flow

Class RMSF

  • Added type hints to __init__() parameters
  • Added return type annotations to _prepare(), _single_frame(), and _conclude() methods: -> None

Configuration

  • Updated mypy.ini to enable type checking for MDAnalysis.analysis.rms module

PR Checklist

  • Issue raised/referenced?
  • Tests updated/added? (No new tests needed - type hints only)
  • Documentation updated/added? (Type hints serve as inline documentation)
  • package/CHANGELOG file updated?
  • Is your name in package/AUTHORS?

Developers Certificate of Origin

I certify that I can submit this code contribution as described in the Developer Certificate of Origin, under the MDAnalysis LICENSE.


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

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello there first time contributor! Welcome to the MDAnalysis community! We ask that all contributors abide by our Code of Conduct and that first time contributors introduce themselves on GitHub Discussions so we can get to know you. You can learn more about participating here. Please also add yourself to package/AUTHORS as part of this PR.

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.72%. Comparing base (bbcef1b) to head (61c8026).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5179      +/-   ##
===========================================
- Coverage    92.72%   92.72%   -0.01%     
===========================================
  Files          180      180              
  Lines        22472    22482      +10     
  Branches      3188     3188              
===========================================
+ Hits         20837    20846       +9     
- Misses        1177     1178       +1     
  Partials       458      458              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant