Skip to content

Commit

Permalink
Update for removing qutip.qip in dev.major (#146)
Browse files Browse the repository at this point in the history
VQA module wrongly used the qutip.qip module, which is removed in qutip-v5.

Update the Measurement class and expand the measurement operator because calling the qutip measurement functions.

See also qutip/qutip#1890.
  • Loading branch information
BoxiLi committed May 28, 2022
1 parent 546a212 commit a32db10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/qutip_qip/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ def measurement_comp_basis(self, state):
else:
raise ValueError("target is not valid")

return measurement_statistics(
state, measurement_ops, targets=self.targets
)
measurement_ops = [
expand_operator(op, N=n, targets=self.targets)
for op in measurement_ops
]
return measurement_statistics(state, measurement_ops)

def __str__(self):
str_name = ("Measurement(%s, target=%s, classical_store=%s)") % (
Expand Down
4 changes: 2 additions & 2 deletions src/qutip_qip/vqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import random
import numpy as np
from qutip import basis, tensor, Qobj, qeye, expect
from qutip.qip.circuit import QubitCircuit
from qutip_qip.circuit import QubitCircuit
from scipy.optimize import minimize
from scipy.linalg import expm_frechet
from qutip.qip.operations.gates import gate_sequence_product
from qutip_qip.operations.gates import gate_sequence_product


class VQA:
Expand Down

0 comments on commit a32db10

Please sign in to comment.