Skip to content

Commit 447f202

Browse files
authored
Merge pull request #68 from eltonjohnfanboy/fix-issue37
Fix issue #37
2 parents 3364463 + 10eeff1 commit 447f202

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

dataset/dataset_qiskit_test_human_eval.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@
675675
"task_id": "qiskitHumanEval/84",
676676
"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 \"\"\"",
677677
"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",
679679
"entry_point": "controlled_custom_unitary_circuit",
680680
"difficulty_scale": "basic"
681681
},
@@ -1019,7 +1019,7 @@
10191019
"task_id": "qiskitHumanEval/127",
10201020
"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 \"\"\"",
10211021
"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",
10231023
"entry_point": "random_circuit_depth",
10241024
"difficulty_scale": "basic"
10251025
},

dataset/dataset_qiskit_test_human_eval_hard.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@
677677
"canonical_solution": "from qiskit import QuantumCircuit\nfrom qiskit.circuit.library import U3Gate\n\ndef controlled_custom_unitary_circuit():\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",
678678
"entry_point": "controlled_custom_unitary_circuit",
679679
"difficulty_scale": "basic",
680-
"test": "from qiskit import QuantumCircuit\nfrom qiskit.circuit.library import U3Gate\ndef 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\ncheck(controlled_custom_unitary_circuit)"
680+
"test": "from qiskit import QuantumCircuit\nfrom qiskit.circuit.library import U3Gate\ndef 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\ncheck(controlled_custom_unitary_circuit)"
681681
},
682682
{
683683
"task_id": "qiskitHumanEval/85",
@@ -1021,7 +1021,7 @@
10211021
"canonical_solution": "from qiskit.circuit.random import random_circuit\nfrom qiskit import QuantumCircuit\n\ndef random_circuit_depth():\n circuit = random_circuit(4, 3, measure=True, seed = 17)\n return circuit\n",
10221022
"entry_point": "random_circuit_depth",
10231023
"difficulty_scale": "basic",
1024-
"test": "from qiskit.circuit.random import random_circuit\nfrom qiskit import QuantumCircuit\ndef 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\ncheck(random_circuit_depth)"
1024+
"test": "from qiskit.circuit.random import random_circuit\nfrom qiskit import QuantumCircuit\ndef 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\ncheck(random_circuit_depth)"
10251025
},
10261026
{
10271027
"task_id": "qiskitHumanEval/128",

0 commit comments

Comments
 (0)