"test": "def check(candidate):\n from qiskit.circuit.library import RXGate, RZGate\n circ = QuantumCircuit(2)\n theta = Parameter(\"θ\")\n circ.rx(0.1, 1)\n circ.ry(theta, 1)\n circ.rx(theta, 0)\n circ.cp(theta, 0, 1)\n circ.rz(0.4, 0)\n circ_can = candidate(circ)\n assert isinstance(circ_can, QuantumCircuit), \"Not a quantum circuit\"\n assert len(circ_can.parameters) == 0, \"Circuit consists of gates with unassigned parameters.\"\n has_rx = False\n has_rz = False\n for instruction in circ_can:\n instr, qargs, cargs = instruction.operation, instruction.qubits, instruction.clbits\n if isinstance(instr, RXGate):\n has_rx = True\n if isinstance(instr, RZGate):\n has_rz = True\n assert has_rx is True, \"Removed rx gates with assigned parameters from the circuit\"\n assert has_rz is True, \"Removed rz gates with assigned parameters from the circuit\"\n",
0 commit comments