fix(hessian): Address code review findings from PRs #81-83#84
Merged
ericchansen merged 2 commits intomasterfrom Mar 20, 2026
Merged
fix(hessian): Address code review findings from PRs #81-83#84ericchansen merged 2 commits intomasterfrom
ericchansen merged 2 commits intomasterfrom
Conversation
- Validate method param in invert_ts_curvature; raise ValueError for unsupported values instead of silently falling through to Method C - Remove bogus element-wise >= 0 check on Hessian matrix (off-diagonal coupling constants are routinely negative; this fired false warnings) - Change detect_problematic_params/lock_params to use canonical param keys instead of fragile list indices - Clarify lock_params docstring: it copies values but does not freeze params during optimization (honest about current limitation) - Fix docstring units: Cartesian Hessian eigenvalues, not mass-weighted - Use natural sort for Jaguar .in file glob in parity tests - Remove unnecessary from __future__ import annotations in test files - Add literature-validated force constant range tests for ethane Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Addresses prior review findings around TS Hessian inversion behavior, parameter locking robustness, and test reliability/validation.
Changes:
- Make
invert_ts_curvature()reject unsupported methods (no silent fallback) and remove a misleading element-wise negativity check. - Switch “problematic parameter” detection/locking from list indices to canonical parameter keys.
- Improve tests: add natural sorting for Jaguar inputs and add independent literature-based validation for ethane.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| test/test_method_d_e.py | Updates tests to use key-based locking/problem detection; adds invalid-method assertion. |
| test/integration/test_seminario_parity.py | Adds a natural sort key for .in files to stabilize parity/benchmark ordering. |
| test/integration/test_ethane_seminario.py | Adds independent literature-range validation tests for ethane force constants. |
| q2mm/models/hessian.py | Enforces method validation, clarifies docs/units, and migrates problematic detection/locking to key-based mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Warn when lock_params source FF is missing requested keys - Align docstring reference to co.HESSIAN_CONVERSION (matches import alias) - Strengthen test_all_problematic with distinct element types for full coverage of multi-problem detection - Use next(..., None) + explicit assert in literature validation tests for clearer failure messages Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Fixes all 8 code review findings from GPT-5.4 and Gemini 3 Pro reviews of PRs #81-83.
Changes
Bug fixes
invert_ts_curvature(method="E")or any typo silently fell through to Method C. Now raisesValueErrorfor unsupported values.if not (inv_curv_hessian >= 0.0).all()checked matrix elements, not eigenvalues. Off-diagonal coupling force constants are routinely negative, so this fired false warnings for every real molecule. Removed entirely.detect_problematic_paramsreturned list indices;lock_paramsused those indices to copy values between force fields with potentially different orderings. Now uses canonical param keys (param.keytuples).Docstring/accuracy fixes
replace_neg_eigenvaluedocstring said "Hartree/bohr^2/amu^-1" butHESSIAN_CONVERSIONhas no mass terms. Clarified: operates on Cartesian Hessian eigenvalues, not mass-weighted.set_param_vectorcan still overwrite them; true freezing requires excluding params from the optimization vector.Test improvements
TestLiteratureValidationclass with independently sourced force constant ranges (MM3/IR spectroscopy) so ethane tests aren't purely self-referential..infile glob in parity tests now uses natural sort key so2.in < 10.inregardless of zero-padding.from __future__ import annotations(user): Removed fromtest_method_d_e.pyandtest_ethane_seminario.py-- not needed on Python 3.10+. Kept inhessian.pywhere it's required forTYPE_CHECKINGpattern.Testing