Skip to content

Add test coverage for missing general_calculations in MolecularData.load#1251

Merged
mhucka merged 11 commits intoquantumlib:mainfrom
mhucka:test-nocover-molecular-data-13735689036354339225
Apr 4, 2026
Merged

Add test coverage for missing general_calculations in MolecularData.load#1251
mhucka merged 11 commits intoquantumlib:mainfrom
mhucka:test-nocover-molecular-data-13735689036354339225

Conversation

@mhucka
Copy link
Copy Markdown
Contributor

@mhucka mhucka commented Mar 31, 2026

This change removes the pragma: nocover and the associated TODO in src/openfermion/chem/molecular_data.py by adding a test case in src/openfermion/chem/molecular_data_test.py that triggers the branch where general_calculations_keys or general_calculations_values are missing from the HDF5 file.

mhucka and others added 2 commits March 31, 2026 21:36
This change removes the `pragma: nocover` and the associated TODO in
`src/openfermion/chem/molecular_data.py` by adding a test case in
`src/openfermion/chem/molecular_data_test.py` that triggers the
branch where `general_calculations_keys` or `general_calculations_values`
are missing from the HDF5 file.
@mhucka mhucka marked this pull request as ready for review March 31, 2026 21:57
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes coverage pragmas and adds a test case for scenarios where general calculations are missing from the HDF5 file. Feedback suggests initializing general_calculations as an empty dictionary rather than None to prevent potential AttributeError during save operations. Additionally, the new test case should be refactored to ensure proper file cleanup and remove redundant initialization calls.

mhucka and others added 2 commits March 31, 2026 15:19
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@mhucka
Copy link
Copy Markdown
Contributor Author

mhucka commented Apr 4, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies MolecularData.load to initialize general_calculations as an empty dictionary when keys are missing and introduces a test case for this behavior. Feedback highlights a remaining edge case that could cause an AttributeError and suggests a more robust initialization. Furthermore, it is recommended to use tempfile.TemporaryDirectory in the tests to ensure compatibility with Windows systems.

mhucka and others added 2 commits April 3, 2026 22:41
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@mhucka
Copy link
Copy Markdown
Contributor Author

mhucka commented Apr 4, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the MolecularData.load method to initialize general_calculations as an empty dictionary instead of None when the corresponding keys are missing from the HDF5 file. It also adds a unit test to verify this behavior using a temporary HDF5 file. A review comment suggests that the current implementation still misses a case where the keys exist but are empty, which could lead to an AttributeError, and provides a code suggestion to handle both scenarios.

@mhucka mhucka merged commit dfa64ca into quantumlib:main Apr 4, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants