from mpqp import QCircuit

circ1 = QCircuit(3)
circ2 = QCircuit(5, nb_cbits=2, label="Example")

from mpqp.gates import *
from mpqp.measures import BasisMeasure
from mpqp import Barrier

circ2.add(CNOT(2,3))
circ2.add([H(0), T(1), CNOT(0,1), S(4)])

circ3 = QCircuit(
    [
        H(0),
        X(1),
        CNOT(1, 2),
        Barrier(),
        Y(2),
        Z(0),
        CZ(1, 0),
        BasisMeasure([0, 1, 2], shots=1024),
    ]
)

print(circ2)

circ3.pretty_print()

circ3.display()

circ3.display("latex")

circ3.depth()

circ3.size()

circ3.count_gates(X)

circ3.get_measurements()

circ1 = QCircuit([H(0), S(1), CNOT(0,1)])
circ2 = QCircuit([X(0)])
print(circ1)
print('-------------')
print(circ2)

appended = circ1 + circ2
print(appended)

tensored = circ1 @ circ2
print(tensored)

from mpqp import Language

circ3.to_other_language(Language.QISKIT)

circ3.to_other_language(Language.MY_QLM)

circ3.to_other_language(Language.BRAKET)

circ3.to_other_language(Language.CIRQ)

print(circ3.to_qasm2())

print(circ3.to_qasm3())

from sympy import symbols

theta, k = symbols("θ k")

param_circ = QCircuit(
    [Rx(theta, 0), CNOT(1,2), X(2), Rk(k,1), H(0), CRk(k, 0, 2),
    BasisMeasure(list(range(3)), shots=1000)]
)

print(param_circ)

import numpy as np
print(param_circ.subs({theta: np.pi/3, k:2}))

param_circ.variables()