result.get_counts(schedule) raises QiskitError
See original GitHub issueInformation
- 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:
- Created 4 years ago
- Comments:14 (13 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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