Replace lattice.get_all_distances with all_mic_distances in Voronoi collections - #64
Merged
Conversation
…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.
There was a problem hiding this comment.
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
VoronoiSiteCollectionandDynamicVoronoiSiteCollectionto compute distance matrices viaall_mic_distances()using a(3,3)lattice_matrix. - Adjusted collection
analyse_structure()methods (and benchmark/test call sites) to passstructure.lattice.matrixthrough 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.
…rix" This reverts commit 031c0f9.
Also fix benchmark to pass lattice_matrix to assign_site_occupations.
There was a problem hiding this comment.
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.
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
force-pushed
the
54-voronoi-distance-function
branch
from
March 21, 2026 07:44
34f1177 to
6d7647d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
VoronoiSiteCollection.assign_site_occupations()andDynamicVoronoiSiteCollection.assign_site_occupations()now take alattice_matrix(numpy array) instead of a pymatgenStructureobjectall_mic_distances()from the distances module instead oflattice.get_all_distances()analyse_structure()extractsstructure.lattice.matrixat the boundary and passes it throughassign_site_occupationsinterface across all SiteCollection implementations (includingPolyhedralSiteCollectionandTrajectory) to acceptlattice_matrixconsistently, avoiding a half-converted state on mainLatticeobjects wherelattice_matrixarrays were expectedPart of the pymatgen decoupling effort (#59). Partially addresses #56.
Closes #54