Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate BasicSimulator.run_experiment #13750

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions qiskit/providers/basic_provider/basic_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,14 @@ def _run_job(self, job_id: str, qobj: QasmQobj) -> Result:
self._memory = getattr(qobj.config, "memory", False)
self._qobj_config = qobj.config
start = time.time()
for experiment in qobj.experiments:
result_list.append(self.run_experiment(experiment))
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
message=r".+qiskit\.providers\.basic_provider\.basic_simulator\..+",
)
for experiment in qobj.experiments:
result_list.append(self.run_experiment(experiment))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In normal circumstances, we would probably want to have an internal _run_experiment and avoid using catch_warnings but this is all going be removed soon anyway.

end = time.time()
result = {
"backend_name": self.name,
Expand All @@ -593,6 +599,13 @@ def _run_job(self, job_id: str, qobj: QasmQobj) -> Result:

return Result.from_dict(result)

@deprecate_func(
since="1.4.0",
removal_timeline="in Qiskit 2.0.0",
additional_msg="This method takes a `QasmQobjExperiment` as input argument. "
"The `Qobj` class and related functionality are part of the deprecated "
"`BackendV1` workflow, and no longer necessary for `BackendV2`. Use `run` instead.",
)
def run_experiment(self, experiment: QasmQobjExperiment) -> dict[str, ...]:
"""Run an experiment (circuit) and return a single experiment result.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
deprecations_providers:
- |
The :meth:`.BasicSimulator.run_experiment` method has been deprecated and will be removed in Qiskit 2.0.0.
The method takes `QasmQobjExperiment` as input argument, which has been deprecated together with the `Qobj`
class and other related functionality. You can `run` with a :class:`.QuantumCircuit` input instead.
ElePT marked this conversation as resolved.
Show resolved Hide resolved
ElePT marked this conversation as resolved.
Show resolved Hide resolved
Loading