Skip to content

Commit

Permalink
Fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
mrossinek committed Feb 15, 2022
1 parent 11abf8b commit da1bec7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion qiskit_nature/drivers/second_quantization/hdf5d/hdf5driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import h5py

from qiskit_nature import QiskitNatureError
from qiskit_nature.hdf5 import load_from_hdf5, save_to_hdf5
from qiskit_nature.properties.second_quantization.second_quantized_property import (
GroupedSecondQuantizedProperty,
Expand Down Expand Up @@ -60,8 +61,11 @@ def work_path(self, new_work_path):
def _get_path(self) -> str:
"""Returns the absolute path to the HDF5 file.
Returns:
The absolute path to the HDF5 file.
Raises:
LoopupError: file not found.
LookupError: file not found.
"""
hdf5_file = self._hdf5_input
if self.work_path is not None and not os.path.isabs(hdf5_file):
Expand Down Expand Up @@ -101,6 +105,7 @@ def run(self) -> GroupedSecondQuantizedProperty:
Raises:
LookupError: file not found.
QiskitNatureError: if the HDF5 file did not contain a GroupedSecondQuantizedProperty.
"""
hdf5_file = self._get_path()

Expand All @@ -122,4 +127,11 @@ def run(self) -> GroupedSecondQuantizedProperty:
return ElectronicStructureDriverResult.from_legacy_driver_result(molecule)

driver_result = load_from_hdf5(hdf5_file)

if not isinstance(driver_result, GroupedSecondQuantizedProperty):
raise QiskitNatureError(
f"Expected a GroupedSecondQuantizedProperty but found a {type(driver_result)} "
"object instead."
)

return driver_result

0 comments on commit da1bec7

Please sign in to comment.