question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pad results with zeros for unmeasured states

See original GitHub issue

What is the expected enhancement?

After executing a job on qiskit, the typically procedure to get the measurement data from the quantum computer is to call get_counts() like so…

job = execute(qc, backend, shots=100)
result = job.result()
counts = result.get_counts()

If the final state is, for example, $| 01 \rangle$ then ‘01’ would be the only key in counts. For some analyses, it would be very useful if the returned counts dictionary had 0s for all the states that were not measured. Maybe something like counts = results.get_counts(pad=True), and counts would then be counts = {'00':0, '01':100, '10':0, '11':0}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jakelishmancommented, Aug 25, 2021

If you try to get valid bitstrings from it, it will return 0 if no counts were seen (and obviously return the correct number if the state was seen). You wouldn’t need an option for it to work; it’d do it by default. Things like print(counts) won’t show the 0s, though - that would involve the exponential behaviour that we can’t safely include.

0reactions
ajrazandercommented, Aug 25, 2021

Ah ok, I see now. Yes, that behavior is even better! Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pad get_counts() with zeros for unmeasured states? (Qiskit)
After executing a job on qiskit, the typically procedure to get the measurement data from the quantum computer is to call get_counts() like...
Read more >
Pad with leading zeros to common width - Stack Overflow
Simply following the advise in @joran's comment, DB <- data.frame( HOUR = c(1, 10, 5, 20), ID = c(2, 4, 6, 6)) NHOUR...
Read more >
Zero filling interpolation | Radiology Reference Article
Zero filling interpolation (ZIP) is the substitution of zeroes for unmeasured data points in order to increase the matrix size of the new ......
Read more >
Retinal microvascular findings and risk of incident peripheral ...
PAD is associated with major clinical outcomes including mortality, ... using a random zero sphygmomanometer after a 5-minute rest.
Read more >
One-time pad - Wikipedia
In cryptography, the one-time pad (OTP) is an encryption technique that cannot be cracked, ... state along a one-way quantum channel (by analogue...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found