Skip to content

Docs: Fix doctest failure in rms.py - #5205

Merged
orbeckst merged 3 commits into
MDAnalysis:developfrom
IAyaanHere:my-first-contribution
Jan 15, 2026
Merged

Docs: Fix doctest failure in rms.py#5205
orbeckst merged 3 commits into
MDAnalysis:developfrom
IAyaanHere:my-first-contribution

Conversation

@IAyaanHere

@IAyaanHere IAyaanHere commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

Contributes to #3925

Changes made in this Pull Request:

  • Fixed rms.py doctest failure by updated the expected output to np.float64(6.838544558398293) so it lines up with what NumPy actually returns
  • Verified that the doctest passes using pytest --doctest-modules.

LLM / AI generated code disclosure

  • No

PR Checklist

  • Issue raised/referenced?
  • Tests updated/added?
  • Documentation updated/added?

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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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

codecov Bot commented Jan 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.73%. Comparing base (9cbc8ea) to head (71eab77).
⚠️ Report is 25 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5205   +/-   ##
========================================
  Coverage    92.72%   92.73%           
========================================
  Files          180      180           
  Lines        22475    22475           
  Branches      3190     3190           
========================================
+ Hits         20841    20843    +2     
+ Misses        1177     1176    -1     
+ Partials       457      456    -1     

☔ 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.

@orbeckst

Copy link
Copy Markdown
Member

Can you show the output of the doc testing before and after your fix?

@orbeckst orbeckst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See comments inline.

Please also show explicitly doc tests output before/after your change.

Comment thread package/MDAnalysis/analysis/rms.py Outdated
Comment on lines 246 to 247
>>> float(rmsd(A, B, center=True))
6.838544558398293

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nobody would normally case the output with float. First and foremost, the docs must be human-readable/human-centered. If the output is different then you could show the different output.

Find a way to make the doc-tests work without introducing code in the example that only serves the doc tests.

@IAyaanHere IAyaanHere Jan 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out, @orbeckst You’re right the float() cast was making the example look a bit off.

I’ve switched the example back to rmsd(A, B, center=True) and updated the expected output to np.float64(6.838544558398293) so it lines up with what NumPy actually returns , I tested it locally and the doctests are passing now.

@orbeckst orbeckst self-assigned this Jan 14, 2026
@orbeckst

Copy link
Copy Markdown
Member

Can you please copy and paste how you ran the local test and the relevant output? Thanks.

@IAyaanHere

Copy link
Copy Markdown
Contributor Author

Can you please copy and paste how you ran the local test and the relevant output? Thanks.

yeah sure @orbeckst , here are the local doctest outputs as requested:

Before (Failing):
The test fails because the returned value is a numpy scalar, but the docstring expected a standard float so we got ,

package\MDAnalysis\analysis\rms.py F                                                            [100%]

============================================== FAILURES ============================================== 
_______________________________ [doctest] MDAnalysis.analysis.rms.rmsd _______________________________ 
246 >>> rmsd(A, B, center=True)
Expected:
    6.838544558398293
Got:
    np.float64(6.838544558398293)

D:\study zone\pandas\mdanalysis\package\MDAnalysis\analysis\rms.py:246: DocTestFailure
====================================== short test summary info =======================================
FAILED package\MDAnalysis\analysis\rms.py::MDAnalysis.analysis.rms.rmsd


**After (Passing):**

after updating the expected output to np.float64(6.838544558398293) and removing the unnecessary float() cast: ,


```package\MDAnalysis\analysis\rms.py .                                                            [100%]

==================================== 1 passed, 1 warning in 3.82s ====================================

@orbeckst orbeckst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the fix! LGTM

@orbeckst
orbeckst merged commit 4c12f15 into MDAnalysis:develop Jan 15, 2026
24 checks passed
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.

2 participants