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.

result.get_counts(schedule) raises QiskitError

See original GitHub issue

Information

  • Qiskit Terra version: master
  • Python version:
  • Operating system:

What is the current behavior?

In qiskit-terra qiskit.result.result.Result._get_experiment, there is an assumption that Schedules always have names. This isn’t true, so trying to get results from a batch job execution gives an error.

Steps to reproduce the problem

When I run

job = execute(list_of_schedules, backend)
result = job.result()
result.get_counts(list_of_schedules[0])

I get the error:

QiskitError: 'Data for experiment "None" could not be found.'

because of these lines:

        # Key is a QuantumCircuit/Schedule or str: retrieve result by name.
        if isinstance(key, (QuantumCircuit, Schedule)):
            key = key.name

where schedule.name is None.

What is the expected behavior?

I should get my data from the result for the given Schedule.

Suggested solutions

We could remove the option to get results by Schedule as a key, and instead only take the index of the experiment for Schedules. We could force Schedules to have a name, but that adds unnecessary work on the user’s side, so I don’t prefer that. We could try to find a different way to match Schedules to their results rather than by Schedule name.

Extra info

This is how I actually made my batch of schedules.

# dt ~= 3.5e-9 from backend
experiments = []
for t in np.round(np.linspace(500e-9 / dt, 20_000e-9 / dt, 40)):
    schedule = Schedule()
    schedule += x_pulse << int(t)    # x_pulse and measure from CmdDef
    schedule += measure << int(t) + x_pulse.duration
    experiments.append(schedule)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
willhbangcommented, Feb 2, 2020

@lcapelluto waiting on review in my PR, i’ll bump it

1reaction
lcapellutocommented, Nov 4, 2019

afaik, yes

Read more comments on GitHub >

github_iconTop Results From Across the Web

qiskit.result.Result.get_counts
experiment (str or QuantumCircuit or Schedule or int or None) – the index of the ... Raises. QiskitError – if there are no...
Read more >
qiskit.result.postprocess.format_counts Example - Program Talk
Learn how to use python api qiskit.result.postprocess.format_counts. ... Raises: QiskitError: if there are no counts for the experiment.
Read more >
Qiskit/qiskit-terra: Qiskit Terra 0.11.0 | Zenodo
Qiskit/qiskit-terra: Qiskit Terra 0.11.0 · Format pulse defaults (#3526) · Add argument to ignore framechange only channels for schedules drawing (#3441) · Use ......
Read more >
Access results from an experiment without having to run the ...
You can get a previous result by grabbing the corresponding job from the backend you sent it to: from qiskit import * provider ......
Read more >
The qiskit-tutorials from Qiskit - GithubHelp
1302 raise QISKitError('No counts for circuit "{0}"'.format(name)) ... https://github.com/qiskit-tutorial/wiki/Running-Quantum-Program-on-IBM-DSx ...
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