Skip to content

Commit

Permalink
remove qiskit execute call (deprecated in qiskit 1.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
dakk committed Mar 22, 2024
1 parent 68ac3dd commit 481695a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/source/bqm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"source": [
"from dwave.system import DWaveSampler, EmbeddingComposite\n",
"\n",
"sampler = EmbeddingComposite(DWaveSampler()) \n",
"sampler = EmbeddingComposite(DWaveSampler())\n",
"sampleset = sampler.sample(bqm, num_reads=10)\n",
"decoded_samples = decode_samples(test_factor, sampleset)\n",
"best_sample = min(decoded_samples, key=lambda x: x.energy)\n",
Expand Down
16 changes: 8 additions & 8 deletions docs/source/example_unitary_of_f.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 1,
"metadata": {},
"outputs": [
{
Expand All @@ -31,13 +31,13 @@
"<Figure size 538.33x367.889 with 1 Axes>"
]
},
"execution_count": 12,
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from qiskit import QuantumCircuit, transpile, execute\n",
"from qiskit import QuantumCircuit, transpile\n",
"from qiskit_aer import AerSimulator\n",
"from qiskit.visualization import array_to_latex\n",
"from qlasskit import qlassf\n",
Expand All @@ -59,7 +59,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -83,16 +83,16 @@
"<IPython.core.display.Latex object>"
]
},
"execution_count": 13,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simulator = AerSimulator(method=\"unitary\")\n",
"job = execute(qc, simulator, shots=8192)\n",
"result = job.result()\n",
"array_to_latex(result.get_unitary(qc, 3), max_size=16)"
"circ = transpile(qc, simulator)\n",
"result = simulator.run(circ).result()\n",
"array_to_latex(result.get_unitary(circ, 3), max_size=16)"
]
}
],
Expand Down
10 changes: 5 additions & 5 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import threading
from typing import get_args

from qiskit import QuantumCircuit, execute, transpile
from qiskit import QuantumCircuit, transpile
from qiskit_aer import Aer, AerSimulator
from sympy.logic.boolalg import gateinputcount

Expand Down Expand Up @@ -98,11 +98,11 @@ def qiskit_measure_and_count(circ, shots=1):


def qiskit_unitary(circ, shots=128):
simulator = AerSimulator(method="unitary")
circ.save_state()
job = execute(circ, simulator, shots=shots)
result = job.result()
return result.get_unitary(circ, 3)
simulator = AerSimulator(method="unitary")
tcirc = transpile(circ, simulator)
result = simulator.run(tcirc, shots=shots).result()
return result.get_unitary(tcirc, 3)


def compute_result_of_qcircuit(cls, qf, truth_line): # noqa: C901
Expand Down

0 comments on commit 481695a

Please sign in to comment.