from may4_challenge.ex4 import get_unitary
U = get_unitary()
from may4_challenge.ex4 import get_unitary
from qiskit import QuantumCircuit, transpile, execute, BasicAer, extensions
from qiskit.visualization import *
from qiskit import QuantumCircuit
from may4_challenge.ex4 import check_circuit, submit_circuit
import numpy as np
import sklearn as sk
import scipy as scipy
from scipy import linalg
from qiskit.visualization import plot_state_city
from qiskit.compiler import transpile
from qiskit import Aer,execute,QuantumRegister


from math import pi
from qiskit import transpile
import scipy
import numpy as np

from qiskit import QuantumCircuit
from may4_challenge.ex4 import check_circuit, submit_circuit

#U = get_unitary()
#pi = 3.141
#print(U)
#print("U has shape", U.shape)

#H = scipy.linalg.hadamard(16)/4
#U = np.dot(H, U)
#U = np.dot(U, H)
#qc = QuantumCircuit(4)
#print(pi)
#qc.u3(pi/2,0,pi,0)
#qc.u3(pi/2,0,pi,1)
#qc.u3(pi/2,0,pi,2)
#qc.u3(pi/2,0,pi,3)
#qc.isometry(U,[0,1,2,3],[])
#qc.u3(pi/2,0,pi,0)
#qc.u3(pi/2,0,pi,1)
#qc.u3(pi/2,0,pi,2)
#qc.u3(pi/2,0,pi,3)
#qc = transpile(qc, basis_gates = ['u3', 'cx'], seed_transpiler=0, optimization_level=2)
#print('gates = ', qc.count_ops())
#print('depth = ', qc.depth()

from scipy.linalg import hadamard
H = hadamard(16, dtype=complex)/4
U = np.dot(H, U)
U = np.dot(U, H)
qc = QuantumCircuit(4)
qc.u3(pi/2,0,pi,range(4))
qc.isometry(U,[0,1,2,3],[])
qc.u3(pi/2,0,pi,range(4))
qc = transpile(qc, basis_gates = ['u3', 'cx'], seed_transpiler=5, optimization_level=2)

##### check your quantum circuit by running the next line
check_circuit(qc)

from may4_challenge.ex4 import submit_circuit

submit_circuit(qc)