Repository navigation
Raise ValueError for malformed FCIDUMP files - #192
Open
ARYAMANN7279 wants to merge 2 commits into
Open
ARYAMANN7279 wants to merge 2 commits into
ARYAMANN7279 wants to merge 2 commits into
Conversation
load_fcidump raised a tuple, which Python 3 turns into a TypeError that hides the message. Raise ValueError instead, close the file in MolHam.from_fcidump, and add tests.
for more information, see https://pre-commit.ci
This branch has not been deployed
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.
load_fcidumphas two error paths that doraise (message, lit), which raises a tuple. In Python 3 this does not show the message, it fails withTypeError: exceptions must derive from BaseException:This changes both to
ValueErrorwith the message.MolHam.from_fcidumpalso calledload_fcidump(open(path))and never closed the file, so it now useswith.I also added
test_fcidump.py: a small handwritten FCIDUMP is read and the integrals are checked in physicists' notation,from_fcidumpis checked, and the two error messages are checked. The two error tests fail without the change. I also compared the loader with PySCF on H2O/STO-3G and a 4-atom H chain in 6-31G (integrals to 1e-14 and the FCI energy to 1e-14) and it is correct for valid files.