Skip to content

fix minor bug in indexing in dipole moment#380

Merged
chrisiacovella merged 5 commits intochoderalab:mainfrom
chrisiacovella:dev-quadrupole
Sep 11, 2025
Merged

fix minor bug in indexing in dipole moment#380
chrisiacovella merged 5 commits intochoderalab:mainfrom
chrisiacovella:dev-quadrupole

Conversation

@chrisiacovella
Copy link
Copy Markdown
Member

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

  • Issue(s) raised/addressed and linked
  • Includes appropriate unit test(s)
  • Appropriate docstring(s) added/updated
  • Appropriate .rst doc file(s) added/updated
  • PR is ready for review

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.86%. Comparing base (adf0b0e) to head (d9b92f9).

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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_moment method by removing configuration-based indexing for atomic numbers
  • Added comprehensive input validation to _calc_center_of_mass method 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.

Comment thread modelforge-curate/modelforge/curate/datasets/curation_baseclass.py Outdated
Comment thread modelforge-curate/modelforge/curate/tests/test_curation_baseclass.py Outdated
chrisiacovella and others added 2 commits September 10, 2025 16:43
…ass.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…s.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@chrisiacovella chrisiacovella merged commit 1f89c84 into choderalab:main Sep 11, 2025
17 checks passed
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.

4 participants