Skip to content

Commit a1c4fac

Browse files
committed
Fix: Ensure QubitOperator is simplified before sparse conversion
1 parent 783c3f8 commit a1c4fac

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/openfermion/linalg/sparse_tools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,7 @@ def get_sparse_operator(operator, n_qubits=None, trunc=None, hbar=1.0):
12681268
elif isinstance(operator, FermionOperator):
12691269
return jordan_wigner_sparse(operator, n_qubits)
12701270
elif isinstance(operator, QubitOperator):
1271+
operator.simplify()
12711272
return qubit_operator_sparse(operator, n_qubits)
12721273
elif isinstance(operator, (BosonOperator, QuadOperator)):
12731274
return boson_operator_sparse(operator, trunc, hbar)

0 commit comments

Comments
 (0)