Skip to content

Commit

Permalink
Upd. Qiskit tests to include cases for MCSU2Gate
Browse files Browse the repository at this point in the history
  • Loading branch information
israelferrazaraujo committed Mar 5, 2023
1 parent 7c75611 commit c1ceaf6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/python/circuit/test_gate_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,18 @@ def test_inverse(self, class_name, gate_class):
elif class_name == "PauliGate":
pauli_string = "IXYZ"
gate = gate_class(pauli_string)
elif class_name == "MCSU2Gate":
num_ctrl_qubits = 7
alpha = np.random.rand() + 1.j * np.random.rand()
beta = np.random.rand() + 1.j * np.random.rand()

length = np.linalg.norm([alpha, beta])
su2 = np.array([
[alpha, -np.conj(beta)],
[beta, np.conj(alpha)]
]) / length

gate = gate_class(su2, num_ctrl_qubits)
else:
gate = gate_class(*float_vector)

Expand Down Expand Up @@ -300,6 +312,17 @@ def test_equivalence_phase(self, gate_class):
params = ["IXYZ"]
if gate_class.__name__ in ["BooleanExpression"]:
params = ["x | y"]
if gate_class.__name__ in ["MCSU2Gate"]:
alpha = np.random.rand() + 1.j * np.random.rand()
beta = np.random.rand() + 1.j * np.random.rand()

length = np.linalg.norm([alpha, beta])
su2 = np.array([
[alpha, -np.conj(beta)],
[beta, np.conj(alpha)]
]) / length
params[0] = su2
params[1] = 7

gate = gate_class(*params)
equiv_lib_list = std_eqlib.get_entry(gate)
Expand Down

0 comments on commit c1ceaf6

Please sign in to comment.