Skip to content

Commit

Permalink
Merge pull request #198 from qmatter-labs/erroneous_real
Browse files Browse the repository at this point in the history
Removed the .real in expval, since PauliwordOp may have complex coeff…
  • Loading branch information
TimWeaving authored Jan 21, 2025
2 parents 813079b + 2c7afca commit c8e8718
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions symmer/operators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ def expval(self, psi: "QuantumState") -> complex:
complex: The expectation value.
"""
if self.n_terms > psi.n_terms and psi.n_terms > 10:
return (psi.dagger * self * psi).real
return psi.dagger * self * psi
else:
if self.n_terms > 1:
@process.parallelize
Expand All @@ -807,7 +807,7 @@ def f(P, psi):
else:
expvals = np.array(single_term_expval(self, psi))

return np.sum(expvals * self.coeff_vec).real
return np.sum(expvals * self.coeff_vec)

def __mul__(self,
mul_obj: Union["PauliwordOp", "QuantumState", complex],
Expand Down
4 changes: 2 additions & 2 deletions symmer/projection/qubit_subspace_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ def build_subspace_objects(self) -> None:
)

def get_reduced_hamiltonian(self,
n_qubits:int=None, aux_operator:PauliwordOp=None
n_qubits:int, aux_operator:PauliwordOp=None
) -> PauliwordOp:
"""
Project the Hamiltonian in line with the desired qubit subspace techqniques
and, in the case of ContextualSubspace, the desired number of qubits.
Args:
n_qubits (int): Number of Qubits. By default, it is set to None.
n_qubits (int): Number of Qubits.
aux_operator (PauliwordOp): Auxiliary operator. By default, it is set to None.
Returns:
Expand Down

0 comments on commit c8e8718

Please sign in to comment.