Skip to content

Commit 885a094

Browse files
authored
Merge branch 'main' into remove-assert-in-jw
2 parents 6e098d2 + 41e01cf commit 885a094

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

docs/fqe/tutorials/hamiltonian_time_evolution_and_expectation_estimation.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@
285285
"cell_type": "markdown",
286286
"metadata": {},
287287
"source": [
288-
"The BCS hamiltonian evovles spin conserved and number broken wavefunctions."
288+
"The BCS hamiltonian evolves spin conserved and number broken wavefunctions."
289289
]
290290
},
291291
{
@@ -357,7 +357,7 @@
357357
"cell_type": "markdown",
358358
"metadata": {},
359359
"source": [
360-
"Exact evolution of individual n-body anti-Hermitian gnerators"
360+
"Exact evolution of individual n-body anti-Hermitian generators"
361361
]
362362
},
363363
{

src/openfermion/chem/molecular_data_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import os
1515
import tempfile
1616
import unittest
17+
from unittest.mock import patch
1718
import h5py
1819
import numpy.random
1920
import scipy.linalg
@@ -367,3 +368,14 @@ def test_load_no_general_calculations(self):
367368
# Load the molecule and check that general_calculations is empty.
368369
new_molecule = MolecularData(filename=filename)
369370
self.assertEqual(new_molecule.general_calculations, {})
371+
372+
def test_get_from_file_exceptions(self):
373+
with patch('h5py.File') as mock_file:
374+
mock_file.return_value.__enter__.return_value.__getitem__.side_effect = KeyError
375+
data = self.molecule.get_from_file("nonexistent_property")
376+
self.assertIsNone(data)
377+
378+
with patch('h5py.File') as mock_file:
379+
mock_file.side_effect = IOError
380+
data = self.molecule.get_from_file("any_property")
381+
self.assertIsNone(data)

0 commit comments

Comments
 (0)