fix: Address code review findings (bugs, DRY, lint, docs)#106
Merged
ericchansen merged 2 commits intomasterfrom Mar 21, 2026
Merged
fix: Address code review findings (bugs, DRY, lint, docs)#106ericchansen merged 2 commits intomasterfrom
ericchansen merged 2 commits intomasterfrom
Conversation
- Fix license mismatch: pyproject.toml and README now correctly say MIT, matching the LICENSE file and upstream nsf-c-cas/q2mm - Fix Gaussian parser bare except: replace with except StopIteration to avoid silently masking parse errors - Fix .fchk Charge field matching: use 'Charge ' (trailing space) to avoid matching 'Charges' array sections - Complete _ATOMIC_SYMBOLS: expand from 22 to 103 elements (Z=1-103), raise ValueError on unsupported atomic numbers instead of silent fallback - Centralize parameter matching: add match_bond/match_angle/match_vdw to ForceField, eliminating duplicated logic in OpenMM and JAX backends - Centralize covalent radii: Tinker backend now imports from molecule.py instead of maintaining a separate dict with inconsistent values - Remove empty q2mm/forcefields/ and q2mm/io/ subpackages - Tighten ruff config: remove global F821/E722 suppression, use per-file ignores for legacy parser modules only - Fix docs: update package structure, correct performance claim, fix import path in ethane example Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses prior review findings by fixing several parsing/metadata bugs, centralizing repeated parameter-matching logic across MM backends, tightening lint configuration, and correcting documentation/examples to reflect the current package structure.
Changes:
- Fixes parsing correctness issues in Gaussian
.out/.fchkhandling and improves.fchkelement/charge robustness. - Refactors OpenMM and JAX backends to reuse centralized ForceField parameter matching helpers; aligns Tinker bond detection radii with the shared molecule model.
- Updates license metadata and refreshes docs/examples to match the current module layout; tightens Ruff ignores to targeted per-file exceptions.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates stated project license to MIT to match LICENSE. |
| q2mm/parsers/gaussian.py | Replaces bare except with except StopIteration during parsing. |
| q2mm/optimizers/objective.py | Fixes .fchk charge header matching; expands atomic number → symbol mapping and raises on unsupported Z. |
| q2mm/models/forcefield.py | Adds centralized match_bond/match_angle/match_vdw helpers; fixes TYPE_CHECKING import for molecule typing. |
| q2mm/backends/mm/tinker.py | Uses shared COVALENT_RADII from molecule.py for bond detection. |
| q2mm/backends/mm/openmm.py | Delegates bond/angle/vdW matching to ForceField.match_* helpers (DRY). |
| q2mm/backends/mm/jax_engine.py | Delegates bond/angle/vdW matching to ForceField.match_* helpers (DRY). |
| pyproject.toml | Updates license metadata/classifier; tightens Ruff ignores to per-file F821 for legacy parsers. |
| examples/ethane/README.md | Fixes import path (q2mm.parsers instead of removed q2mm.io). |
| docs/performance.md | Corrects OpenMM vs Tinker performance statement. |
| docs/getting-started.md | Updates package tree to reflect current modules (removes non-existent packages). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove redundant element fallback in match_vdw() — get_vdw() already handles atom_type→element fallback internally (review feedback) - Add per-file F821 ignore for test/test_linear_algebra.py (legacy test with undefined refs, caught by tightened global lint config) 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
Address findings from a comprehensive multi-model code review (Claude Opus, Gemini 3 Pro, GPT-5.3 Codex). Fixes bugs, eliminates code duplication, tightens lint config, and corrects documentation.
Changes
Bug Fixes
pyproject.tomlandREADME.mdnow correctly say MIT, matching theLICENSEfile and upstreamnsf-c-cas/q2mmexcept:: replaced withexcept StopIteration:to avoid silently masking parse errors (parsers/gaussian.py).fchkCharge field over-broad match:line.startswith("Charge")also matched"Charges"array sections, silently corrupting the parsed molecular charge. Fixed to"Charge "(trailing space) (optimizers/objective.py)_ATOMIC_SYMBOLS: expanded from 22 to 103 elements (Z=1-103). Unsupported atomic numbers now raiseValueErrorinstead of silently producing"X{z}"fallback symbols that causeKeyErrordownstream (optimizers/objective.py)DRY Refactors
match_bond(),match_angle(),match_vdw()toForceField, eliminating duplicated cascade logic in OpenMM and JAX backends (models/forcefield.py,backends/mm/openmm.py,backends/mm/jax_engine.py)TinkerEngine._detect_bonds()now importsCOVALENT_RADIIfrommolecule.pyinstead of maintaining a separate dict with inconsistent values (Cl: 0.99 vs 1.02, Br: 1.14 vs 1.20) (backends/mm/tinker.py)Hygiene
q2mm/forcefields/andq2mm/io/contained only__pycache__but were shipped in the distributionF821(undefined name) andE722(bare except) suppressions; moved to per-file ignores for legacy parser modules only (pyproject.toml)TYPE_CHECKINGimport: resolvedF821forQ2MMMoleculetype hint inforcefield.pyDocumentation
docs/getting-started.md(removed phantomforcefields/andio/modules)docs/performance.md(was "1.6x faster", should be "~150x higher throughput")examples/ethane/README.md(q2mm.io->q2mm.parsers)Testing
ruff checkpasses with zero violations