3
$\begingroup$

Suppose Circuits= [circuit1, circuit2, ..., circuitn] is a list of defined circuits. Then, job = execute(Circuits, backend=backend, shots=shots, max_credits=max_credits) will execute a list of circuits all together. Then, one can get the result by using job.result().get_counts. It looks like this (with the results of the first circuit execution highlighted): enter image description here

Is there any way to extract the counts like how it usually is with only one circuit in execution?

$\endgroup$

2 Answers 2

3
$\begingroup$

From the Getting started tutorial on Qiskit, it seems that you grab the result of job first and you access the counts via the function get_counts(circuit) for a specific circuit. So I would loop through Circuits and use this function on each:

result_submissions = job.result()
for qc in Circuits:
     counts = result_submissions.get_counts(qc)
     print(counts)
$\endgroup$
2
  • $\begingroup$ I'm sorry I should have mentioned probably, but I only have two circuits qc and qc5 and my list is: Circuits= [qc, qc5, qc, qc5, qc, qc5, qc, qc5], so by looking at job.result().get_counts I get 8 different (but unexpectedly close) sets of values, but by looping over qc in Circuits I only get two sets of values, repeated four times. $\endgroup$
    – Mathist
    Commented Jan 7, 2019 at 2:41
  • $\begingroup$ @Mathophile-Mathochist I guess that is because the execute function on a list sample independently and the get_counts take the first result circuit as reference. Maybe you can try calling get_counts() with the parenthesis then see if you have access to the results argument which you may be able to loop through and use the get_counts() method if the ExperimentResult class has one. $\endgroup$
    – cnada
    Commented Jan 7, 2019 at 3:40
2
$\begingroup$

You can still use the get_counts() function:

result = job_exp.result()
result.get_counts(arg)

The key here is that that function takes different arguments: simply an integer representing the index of the circuit on the Circuits list, the circuit object itself, and the circuit.name attribute (I think). You can check this on the documentation.

So even if you have the same circuit several times in the the Circuits list, you can still correctly identify each circuit by using the index referring to its position on the said list.

This goes a bit late, but might still be useful for someone.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.