Skip to content

Commit

Permalink
Add input data check for Sampler (#519)
Browse files Browse the repository at this point in the history
* add input data check for sampler

* update

* update

* remove a validation check

* move the check to BaseSampler

* remove the unit test

Co-authored-by: Jessie Yu <[email protected]>
  • Loading branch information
t-imamichi and jyu00 authored Sep 21, 2022
1 parent 6e87fe8 commit 408cbee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions qiskit_ibm_runtime/qiskit/primitives/base_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,14 @@ def run(
f"the number of parameters ({circuit.num_parameters}) for the {i}-th circuit."
)

for i, circuit in enumerate(circuits):
if circuit.num_clbits == 0:
raise QiskitError(
f"The {i}-th circuit does not have any classical bit. "
"Sampler requires classical bits, plus measurements "
"on the desired qubits."
)

return self._run(circuits, parameter_values, parameter_views, **run_options)

@abstractmethod
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

---
upgrade:
- |
Added a validation check to :meth:`~qiskit_ibm_runtime.Sampler.run`.
It raises an error if there is no classical bit.

0 comments on commit 408cbee

Please sign in to comment.