fix minor bug in indexing in dipole moment#380
Merged
chrisiacovella merged 5 commits intochoderalab:mainfrom Sep 11, 2025
Merged
fix minor bug in indexing in dipole moment#380chrisiacovella merged 5 commits intochoderalab:mainfrom
chrisiacovella merged 5 commits intochoderalab:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
… be causing issues
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the center of mass calculation within the dipole moment computation. The bug occurred when indexing atomic numbers by configuration number, even though atomic numbers have shape [n_atoms, 1] rather than [n_configs, n_atoms, 1].
- Fixed incorrect indexing in
compute_dipole_momentmethod by removing configuration-based indexing for atomic numbers - Added comprehensive input validation to
_calc_center_of_massmethod with proper shape checking - Enhanced test coverage with additional test cases for center of mass calculation and dipole moment edge cases
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test_curation_baseclass.py | Added new test function for center of mass calculation and expanded dipole moment tests |
| curation_baseclass.py | Fixed indexing bug and added input validation to center of mass calculation |
| docs_env.yaml | Commented out a git dependency (unrelated to main fix) |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…ass.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…s.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
MarshallYan
approved these changes
Sep 11, 2025
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.
Pull Request Summary
This fixes a bug in the center of mass calculation in the curation base class... it indexes into a the atomic numbers by "configuration" even though atomic numbers are not encoded with the first dimension as configuration number (i.e., the size [n_atoms, 1], not [n_configs, n_atoms, 1]. This seemed to elude the test which produced a very good estimate of the dipole moment (likely because the center of mass was already really close to zero).
Tests have been be revised to ensure this will not be an issue.
I'll note, this isn't used within training, only as a helper function for datasets.
Pull Request Checklist