Skip to content

Standardize atomicdistances to use results#5347

Draft
charity-g wants to merge 11 commits intoMDAnalysis:developfrom
charity-g:standardize-atomicdistances-to-use-results
Draft

Standardize atomicdistances to use results#5347
charity-g wants to merge 11 commits intoMDAnalysis:developfrom
charity-g:standardize-atomicdistances-to-use-results

Conversation

@charity-g
Copy link
Copy Markdown

@charity-g charity-g commented Mar 28, 2026

Fixes #4819

Changes made in this Pull Request:

LLM / AI generated code disclosure

LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: no

PR Checklist

  • Issue raised/referenced?
  • Tests updated/added?
  • Documentation updated/added?
  • package/CHANGELOG file updated?
  • Is your name in package/AUTHORS? (If it is not, add it!)
  • LLM/AI disclosure was updated.

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--5347.org.readthedocs.build/en/5347/

Copy link
Copy Markdown
Member

@BradyAJohnston BradyAJohnston left a comment

Choose a reason for hiding this comment

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

Some suggestions that should fix the issues with running tests.

The black formatter is also failing. You can run it like this:

uvx black~=24.0 package

# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations.
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
#
from mdanalysis.package.MDAnalysis.analysis.results import Results
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.

This is what's causing your tests to fail - this mdanalysis.package.MDAnalysis only exists on local file system. You should always just import directly from MDAnalysis - which will become available if you us pip install -e . or uv pip install -e ..


"""

from mdanalysis.package.MDAnalysis.analysis.results import (
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.

same issue with imports as in other comment.

@orbeckst
Copy link
Copy Markdown
Member

@charity-g based on discussion in #4822 (comment) we will continue with this PR. Have a look at @BradyAJohnston 's comments and feel free to take it out of draft mode.

Copy link
Copy Markdown
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.

The first thing is to make the code (and tests) run, following Brady's comments. Then please address my inline comments. Focus this PR just on the API change. CHANGELOG and docs must be very clear.

Number of atoms in each atom group.


.. versionadded:: 2.5.0
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.

do not remove any of the versionchanged/versionadded; just add the new one below

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.

and do not remove empty lines – they are necessary for the proper formatting

* Fixes the verbose=False in EinsteinMSD, and only shows progress bar when
verbose=True (Issue #5144, PR #5153)
* Fix incorrect assignment of topology_format to format (and vice versa)
* Fix incorrect assignment of topology_format to format (and vexice versa)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure why this is changed.

import numpy as np

from MDAnalysis.lib.distances import calc_bonds
from MDAnalysis.analysis.results import (
Copy link
Copy Markdown
Contributor

@jeremyleung521 jeremyleung521 Apr 10, 2026

Choose a reason for hiding this comment

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

Could probably remove the comma and parenthesis to truncate into one line

def _single_frame(self):
# if PBCs considered, get box size
box = self._ag1.dimensions if self._pbc else None
self.results[self._frame_index] = calc_bonds(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

https://github.com/MDAnalysis/mdanalysis/actions/runs/23987727902/job/69962349164?pr=5347#step:8:518

Tests show that an all zeros array is passed back in both tests, suggesting the actual numbers/results are not saved properly into the Results object. This is the most important part of the PR(!) so please triple check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

analysis.atomicdistances.AtomicDistances does not use Results

6 participants