Fix load_many crash on single-atom/single-step FCHK optimizations#404
Conversation
be23fce to
357d963
Compare
for more information, see https://pre-commit.ci
|
@Ao-chuba Thanks for working on this. (Minor point: Instead of mentioning the issue being fixed in the PR title, you can add |
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #386 by fixing a LoadError in load_many when processing FCHK files from single-atom or single-step optimizations where the standard trajectory block (IRC/Optimization Number of geometries) is missing.
Changes:
- Added fallback logic to construct a single-frame trajectory from current geometry data when trajectory blocks are absent
- Refactored frame creation into a reusable
_create_framehelper function - Added regression test and test data to verify the fix
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| iodata/formats/fchk.py | Implements fallback for missing trajectory blocks and refactors frame creation into _create_frame helper function |
| iodata/test/test_fchk_single_atom.py | Adds regression test for single-atom optimization loading |
| iodata/test/data/atom_opt.fchk | Test data file representing a single-atom hydrogen optimization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tovrstra
left a comment
There was a problem hiding this comment.
Copilot picked up a few good points to check.
Just one minor question from the human reviewer. Do you suggest generally splitting up the test files? (So far, we've been keeping tests related to each format together in one file, to reuse utility functions.)
That makes total sense regarding utility reuse. I completely agree it's better to keep the tests consolidated for consistency. |
tovrstra
left a comment
There was a problem hiding this comment.
Apologies for having been out of touch for a while. All looks good. Thanks!
|
@tovrstra no worries Sir, your Welcome . |
This PR fixes a LoadError in
load_manyfor single-atom or single-step FCHK optimizations where the trajectory block is missing.Changes :
iodata/formats/fchk.py : Added a fallback to construct a single frame trajectory from
Current cartesian coordinates,Total Energy, andCartesian Gradientwhen the standard trajectory block is absent but the file is an optimization (FOpt,Scan,IRC).Tests: Added regression test

iodata/test/test_fchk_single_atom.pyand dataiodata/test/data/atom_opt.fchkto verify the fix and prevent regression.I ran a manual test script against the newly added regression data (
_iodata/test/data/atom_opt.fchk_) to verify the fix before submitting. As shown in the screenshot,load_manynow correctly parses the file, extracting 1framewith the expected energy (-0.4665...) and coordinates, instead of crashing.Closes #386