Docs: Fix doctest failures in align.py #5207
Open
+5
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Docs: Fix failing doctests in MDAnalysis.analysis.align
Fixed failing doctests in
package/MDAnalysis/analysis/align.pycaused by NumPy scalar types and non-deterministic memory addresses.Details:
NumPy Scalars & Mixed Types:
Functions like
rmsd()andalignto()are now returningnp.float64(or a mixed tuple ofnp.float64andfloat) instead of just plain floats. I updated the docstrings to match the actual output.Before (Failing):
Memory Address (RAM) Issue: The AlignTraj example was failing because the object print includes a memory address (e.g., 0x00...), which changes on every run. The standard ellipsis ... wasn't catching it properly on my environment.
Before (Failing):
Expected:
<MDAnalysis.analysis.align.AlignTraj object at ...>
Got:
<MDAnalysis.analysis.align.AlignTraj object at 0x000001D789C0F770>
After: Suppressed the output using _ = ... to make the test deterministic.
Verification: Ran tests locally:
pytest --doctest-modules package/MDAnalysis/analysis/align.pyResult: 2 passed (All warnings unrelated to changes).LLM / AI generated code disclosure
LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: no
PR Checklist
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--5207.org.readthedocs.build/en/5207/