diff --git a/test/python/circuit/test_rust_equivalence.py b/test/python/circuit/test_rust_equivalence.py index 8d6d159c0b64..b20db4c79f94 100644 --- a/test/python/circuit/test_rust_equivalence.py +++ b/test/python/circuit/test_rust_equivalence.py @@ -18,7 +18,7 @@ import numpy as np -from qiskit.circuit import QuantumCircuit +from qiskit.circuit import QuantumCircuit, CircuitInstruction from qiskit.circuit.library.standard_gates import get_standard_gate_name_mapping SKIP_LIST = {"rx", "ry", "ecr"} @@ -39,6 +39,21 @@ def setUp(self): gate = gate.base_class(*[pi] * len(gate.params)) qc.append(gate, list(range(gate.num_qubits))) + def test_gate_cross_domain_conversion(self): + """Test the rust -> python conversion returns the right class.""" + for name, gate_class in self.standard_gates.items(): + standard_gate = getattr(gate_class, "_standard_gate", None) + if standard_gate is None: + # Gate not in rust yet or no constructor method + continue + with self.subTest(name=name): + qc = QuantumCircuit(standard_gate.num_qubits) + qc._append( + CircuitInstruction(standard_gate, qubits=qc.qubits, params=gate_class.params) + ) + self.assertEqual(qc.data[0].operation.base_class, gate_class.base_class) + self.assertEqual(qc.data[0].operation, gate_class) + def test_definitions(self): """Test definitions are the same in rust space.""" for name, gate_class in self.standard_gates.items():