Skip to content

Commit c8e8718

Browse files
authored
Merge pull request #198 from qmatter-labs/erroneous_real
Removed the .real in expval, since PauliwordOp may have complex coeff…
2 parents 813079b + 2c7afca commit c8e8718

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

symmer/operators/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ def expval(self, psi: "QuantumState") -> complex:
796796
complex: The expectation value.
797797
"""
798798
if self.n_terms > psi.n_terms and psi.n_terms > 10:
799-
return (psi.dagger * self * psi).real
799+
return psi.dagger * self * psi
800800
else:
801801
if self.n_terms > 1:
802802
@process.parallelize
@@ -807,7 +807,7 @@ def f(P, psi):
807807
else:
808808
expvals = np.array(single_term_expval(self, psi))
809809

810-
return np.sum(expvals * self.coeff_vec).real
810+
return np.sum(expvals * self.coeff_vec)
811811

812812
def __mul__(self,
813813
mul_obj: Union["PauliwordOp", "QuantumState", complex],

symmer/projection/qubit_subspace_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ def build_subspace_objects(self) -> None:
108108
)
109109

110110
def get_reduced_hamiltonian(self,
111-
n_qubits:int=None, aux_operator:PauliwordOp=None
111+
n_qubits:int, aux_operator:PauliwordOp=None
112112
) -> PauliwordOp:
113113
"""
114114
Project the Hamiltonian in line with the desired qubit subspace techqniques
115115
and, in the case of ContextualSubspace, the desired number of qubits.
116116
117117
Args:
118-
n_qubits (int): Number of Qubits. By default, it is set to None.
118+
n_qubits (int): Number of Qubits.
119119
aux_operator (PauliwordOp): Auxiliary operator. By default, it is set to None.
120120
121121
Returns:

0 commit comments

Comments
 (0)