Skip to content

Replace lattice.get_all_distances with all_mic_distances in Voronoi collections - #64

Merged
bjmorgan merged 7 commits into
mainfrom
54-voronoi-distance-function
Mar 21, 2026
Merged

Replace lattice.get_all_distances with all_mic_distances in Voronoi collections#64
bjmorgan merged 7 commits into
mainfrom
54-voronoi-distance-function

Conversation

@bjmorgan

@bjmorgan bjmorgan commented Mar 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • VoronoiSiteCollection.assign_site_occupations() and DynamicVoronoiSiteCollection.assign_site_occupations() now take a lattice_matrix (numpy array) instead of a pymatgen Structure object
  • Uses all_mic_distances() from the distances module instead of lattice.get_all_distances()
  • analyse_structure() extracts structure.lattice.matrix at the boundary and passes it through
  • Unifies the assign_site_occupations interface across all SiteCollection implementations (including PolyhedralSiteCollection and Trajectory) to accept lattice_matrix consistently, avoiding a half-converted state on main
  • Fixes pre-existing test calls passing Lattice objects where lattice_matrix arrays were expected

Part of the pymatgen decoupling effort (#59). Partially addresses #56.

Closes #54

…teCollection

Use the numpy distance function from site_analysis.distances instead
of pymatgen Lattice.get_all_distances(). assign_site_occupations now
takes a lattice matrix instead of a Structure.

Part of #54
…ronoiSiteCollection

Same change as VoronoiSiteCollection: assign_site_occupations now
takes a lattice matrix and uses all_mic_distances() from the
distances module.

Closes #54
Trajectory.assign_site_occupations() now extracts structure.lattice.matrix
and passes it to the site collection, matching the updated signatures.
Also fixes British English in voronoi_site_collection module docstring and
the benchmark file's direct assign_site_occupations call.

Copilot AI 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.

Pull request overview

This PR advances the pymatgen-decoupling work by switching Voronoi-based site assignment from pymatgen.Lattice.get_all_distances() to the internal NumPy-based all_mic_distances() API, pushing structure.lattice.matrix extraction to the analysis boundary.

Changes:

  • Updated VoronoiSiteCollection and DynamicVoronoiSiteCollection to compute distance matrices via all_mic_distances() using a (3,3) lattice_matrix.
  • Adjusted collection analyse_structure() methods (and benchmark/test call sites) to pass structure.lattice.matrix through to assignment.
  • Updated trajectory delegation/tests to pass a lattice matrix instead of a Structure.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
site_analysis/voronoi_site_collection.py Switches distance calculation to all_mic_distances() and changes assignment API to accept lattice_matrix.
site_analysis/dynamic_voronoi_site_collection.py Same switch for dynamic Voronoi assignment + passes lattice matrix through analysis pipeline.
site_analysis/trajectory.py Changes delegation in Trajectory.assign_site_occupations() to pass structure.lattice.matrix.
tests/test_voronoi_site_collection.py Updates mocks/assertions to expect lattice_matrix and patch all_mic_distances().
tests/test_dynamic_voronoi_site_collection.py Updates calls to pass structure.lattice.matrix into assignment and batch centre calculation.
tests/test_trajectory.py Updates delegation test to assert lattice-matrix-based call.
tests/benchmark_dynamic_voronoi.py Updates benchmark helper to pass structure.lattice.matrix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_trajectory.py Outdated
Comment thread site_analysis/trajectory.py Outdated
Comment thread site_analysis/voronoi_site_collection.py
Comment thread site_analysis/dynamic_voronoi_site_collection.py
Also fix benchmark to pass lattice_matrix to assign_site_occupations.

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread site_analysis/voronoi_site_collection.py Outdated
Comment thread tests/test_voronoi_site_collection.py
Update the abstract SiteCollection.assign_site_occupations() and all
implementations to accept lattice_matrix (numpy array) instead of
Structure. Trajectory.assign_site_occupations() extracts
structure.lattice.matrix at the boundary before delegating.

PolyhedralSiteCollection accepts lattice_matrix for interface
consistency (not currently used for containment checks).

Partially addresses #56
@bjmorgan
bjmorgan force-pushed the 54-voronoi-distance-function branch from 34f1177 to 6d7647d Compare March 21, 2026 07:44
@bjmorgan
bjmorgan merged commit c90febe into main Mar 21, 2026
6 checks passed
@bjmorgan
bjmorgan deleted the 54-voronoi-distance-function branch March 21, 2026 08:06
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.

Voronoi collections use new distance function

2 participants