Add test coverage for missing general_calculations in MolecularData.load#1251
Conversation
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.
There was a problem hiding this comment.
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.
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>
|
/gemini review |
There was a problem hiding this comment.
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.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
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.
This change removes the
pragma: nocoverand the associated TODO insrc/openfermion/chem/molecular_data.pyby adding a test case insrc/openfermion/chem/molecular_data_test.pythat triggers the branch wheregeneral_calculations_keysorgeneral_calculations_valuesare missing from the HDF5 file.