docs: add mathematical formulas to fitting classes#5256
docs: add mathematical formulas to fitting classes#5256iProzd merged 4 commits intodeepmodeling:masterfrom
Conversation
Add mathematical formulas to fitting class docstrings: - DipoleFitting: dipole computation from rotation matrix - PolarFitting: polarizability tensor with diagonal/full fitting Follow numpydoc convention: parameters in class docstring.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughExtended class-level docstrings in two fitting modules to add detailed mathematical descriptions of how dipole vectors and polarizability tensors are computed from network outputs and rotation matrices; no functional code or public API signatures changed. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@deepmd/dpmodel/fitting/polarizability_fitting.py`:
- Around line 58-64: The docstring's full-matrix formula is misleading because
the implementation symmetrizes the network output (out = (out +
xp.matrix_transpose(out)) / 2) before constructing alpha; update the docstring
in polarizability_fitting.py to state that P^i is the symmetrized prediction
(e.g., P^i_sym = (P^i + P^{i,T})/2) or explicitly replace \mathbf{P}^i in the
formula with its symmetric form, and mention that this symmetrization is applied
when fit_diag=False so the resulting \boldsymbol{\alpha}^i is guaranteed
symmetric.
The full matrix fitting symmetrizes the network output before use: P = (P_raw + P_raw^T) / 2, ensuring a symmetric polarizability tensor.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5256 +/- ##
=======================================
Coverage 82.00% 82.00%
=======================================
Files 750 750
Lines 75082 75080 -2
Branches 3615 3615
=======================================
+ Hits 61572 61573 +1
+ Misses 12347 12345 -2
+ Partials 1163 1162 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds more explicit mathematical formulas to fitting class docstrings (numpydoc-style) to clarify how dipole and polarizability tensors are computed from network outputs and rotation matrices.
Changes:
- Expanded
DipoleFittingdocstring with math for dipole computation and network definition. - Expanded
PolarFittingdocstring with math for diagonal vs full polarizability fitting modes. - Corrected a typo in the
DipoleFittingclass description.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| deepmd/dpmodel/fitting/polarizability_fitting.py | Adds detailed math documentation for diagonal/full polarizability fitting and network outputs. |
| deepmd/dpmodel/fitting/dipole_fitting.py | Adds dipole computation formula and network definition; fixes “diploe” typo. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- dipole_fitting: add 'an' before 'activation function' - polarizability_fitting: add R^i shape, clarify local-frame tensor, explain symmetry preservation in A^T S A form
|
Fixed:
Commit: c735ce9 |
Add explicit definition of m_1 as the embedding width in both dipole_fitting and polarizability_fitting docstrings.
Summary
Add detailed mathematical formulas to fitting class docstrings following numpydoc convention.
Changes
Added formulas to the following classes:
DipoleFitting: Dipole computation from rotation matrix
PolarFitting: Polarizability tensor with diagonal/full fitting modes
Convention
Following numpydoc convention, parameters are documented in class docstrings, not in
__init__docstrings.Statistics
Authored by OpenClaw (model: GLM-5)
Summary by CodeRabbit