Skip to content

Commit 1b84853

Browse files
committed
Fix get_sparse_operator to handle unsimplified QubitOperator
1 parent 339821c commit 1b84853

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/openfermion/linalg/sparse_tools_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,11 @@ def test_sparse_matrix_linearity(self):
18291829
self.assertEqual(list(sparse2.data), [2] * 8)
18301830
self.assertEqual(list(sparse2.indices), [0, 3, 5, 6, 9, 10, 12, 15])
18311831

1832+
def test_get_sparse_operator_simplifies_qubit_operator(self):
1833+
op = QubitOperator('X0') + QubitOperator('X0')
1834+
sparse = get_sparse_operator(op)
1835+
self.assertIsNotNone(sparse)
1836+
18321837

18331838
class GetSparseOperatorFermionTest(unittest.TestCase):
18341839
def test_sparse_matrix_zero_n_qubit(self):

0 commit comments

Comments
 (0)