From c1ceaf6b28830caa5709cdb6e8d4db209acc8c84 Mon Sep 17 00:00:00 2001 From: "Israel F. Araujo" Date: Sun, 5 Mar 2023 13:36:06 +0900 Subject: [PATCH] Upd. Qiskit tests to include cases for MCSU2Gate --- test/python/circuit/test_gate_definitions.py | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/python/circuit/test_gate_definitions.py b/test/python/circuit/test_gate_definitions.py index b7d5f4f06834..32f1baa88fa0 100644 --- a/test/python/circuit/test_gate_definitions.py +++ b/test/python/circuit/test_gate_definitions.py @@ -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) @@ -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)