|
675 | 675 | "task_id": "qiskitHumanEval/84", |
676 | 676 | "prompt": "from qiskit import QuantumCircuit\nfrom qiskit.circuit.library import U3Gate\ndef controlled_custom_unitary_circuit():\n \"\"\" Create a 2-qubit quantum circuit where you define a custom 1-qubit unitary gate (e.g., U3) and apply it as a controlled gate with qubit 0 as control and qubit 1 as target. Return the final circuit.\n \"\"\"", |
677 | 677 | "canonical_solution": "\n qc = QuantumCircuit(2)\n custom_gate = U3Gate(0.3, 0.2, 0.1).control()\n qc.append(custom_gate, [0, 1])\n return qc\n", |
678 | | - "test": "def check(candidate):\n qc = candidate()\n assert isinstance(qc, QuantumCircuit)\n assert qc.num_qubits == 2\n assert any(instr[0].name.startswith('cu3') or 'u3' in instr[0].name for instr in qc.data)\n", |
| 678 | + "test": "def check(candidate):\n qc = candidate()\n assert isinstance(qc, QuantumCircuit)\n assert qc.num_qubits == 2\n assert any(instr.operation.name.startswith('cu3') or 'u3' in instr.operation.name for instr in qc.data)\n", |
679 | 679 | "entry_point": "controlled_custom_unitary_circuit", |
680 | 680 | "difficulty_scale": "basic" |
681 | 681 | }, |
|
1019 | 1019 | "task_id": "qiskitHumanEval/127", |
1020 | 1020 | "prompt": "from qiskit.circuit.random import random_circuit\nfrom qiskit import QuantumCircuit\ndef random_circuit_depth():\n \"\"\" Using qiskit's random_circuit function, generate a circuit with 4 qubits and a depth of 3 that measures all qubits at the end. Use the seed value 17 and return the generated circuit.\n \"\"\"", |
1021 | 1021 | "canonical_solution": "\n circuit = random_circuit(4, 3, measure=True, seed = 17)\n return circuit\n", |
1022 | | - "test": "def check(candidate):\n from qiskit.circuit.random import random_circuit\n from qiskit import QuantumCircuit\n\n # Run the candidate function\n result = candidate()\n\n # Check if the output is a QuantumCircuit\n assert isinstance(result, QuantumCircuit), \"Output should be a QuantumCircuit\"\n\n # Generate the expected circuit using the same parameters\n expected_qc = random_circuit(4, 3, measure=True, seed=17)\n\n # Ensure the circuit has 4 qubits\n assert result.num_qubits == 4, f\"Expected 4 qubits, but got {result.num_qubits}\"\n\n # Ensure the circuit depth is within an acceptable range (allowing small variations)\n expected_depth = expected_qc.depth()\n assert abs(result.depth() - expected_depth) <= 1, f\"Expected depth around {expected_depth}, but got {result.depth()}\"\n\n # Check if all qubits are measured at the end\n measured_qubits = [op for op, qargs, _ in result.data if op.name == \"measure\"]\n assert len(measured_qubits) == 4, \"All qubits should be measured at the end\"\n\n # Ensure the generated circuit matches the expected circuit structure\n assert result == expected_qc, \"Generated circuit does not match expected circuit\"\n", |
| 1022 | + "test": "def check(candidate):\n from qiskit.circuit.random import random_circuit\n from qiskit import QuantumCircuit\n\n # Run the candidate function\n result = candidate()\n\n # Check if the output is a QuantumCircuit\n assert isinstance(result, QuantumCircuit), \"Output should be a QuantumCircuit\"\n\n # Generate the expected circuit using the same parameters\n expected_qc = random_circuit(4, 3, measure=True, seed=17)\n\n # Ensure the circuit has 4 qubits\n assert result.num_qubits == 4, f\"Expected 4 qubits, but got {result.num_qubits}\"\n\n # Ensure the circuit depth is within an acceptable range (allowing small variations)\n expected_depth = expected_qc.depth()\n assert abs(result.depth() - expected_depth) <= 1, f\"Expected depth around {expected_depth}, but got {result.depth()}\"\n\n # Check if all qubits are measured at the end\n measured_qubits = [inst for inst in result.data if inst.operation.name == \"measure\"]\n assert len(measured_qubits) == 4, \"All qubits should be measured at the end\"\n\n # Ensure the generated circuit matches the expected circuit structure\n assert result == expected_qc, \"Generated circuit does not match expected circuit\"\n", |
1023 | 1023 | "entry_point": "random_circuit_depth", |
1024 | 1024 | "difficulty_scale": "basic" |
1025 | 1025 | }, |
|
0 commit comments