Skip to content

Commit

Permalink
Remove execute() function (Qiskit#11565)
Browse files Browse the repository at this point in the history
* port 11044

* reno

* upgrade reno

* docs

* adapt test

* Update examples/python/using_qiskit_terra_level_0.py

Co-authored-by: Elena Peña Tapia <[email protected]>

* example

* docs qiskit.execute_function.execute

* docs adapting

* doc index

---------

Co-authored-by: Elena Peña Tapia <[email protected]>
  • Loading branch information
1ucian0 and ElePT authored Jan 24, 2024
1 parent c63bda7 commit 1a027ac
Show file tree
Hide file tree
Showing 48 changed files with 262 additions and 624 deletions.
6 changes: 0 additions & 6 deletions docs/apidoc/execute.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/apidoc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ API Reference
circuit_classical
circuit_singleton
compiler
execute
visualization
classicalfunction
converters
Expand Down
4 changes: 2 additions & 2 deletions examples/python/ghz.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""

from qiskit import QuantumCircuit
from qiskit import BasicAer, execute
from qiskit import BasicAer, transpile


###############################################################
Expand All @@ -35,7 +35,7 @@
qc.measure(i, i)

sim_backend = BasicAer.get_backend("qasm_simulator")
job = execute(qc, sim_backend, shots=1024)
job = sim_backend.run(transpile(qc, sim_backend), shots=1024)
result = job.result()
print("Qasm simulator : ")
print(result.get_counts(qc))
4 changes: 2 additions & 2 deletions examples/python/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""

import math
from qiskit import QuantumCircuit, execute, BasicAer
from qiskit import QuantumCircuit, transpile, BasicAer


###############################################################
Expand Down Expand Up @@ -59,7 +59,7 @@

# Initialize on local simulator
sim_backend = BasicAer.get_backend("qasm_simulator")
job = execute(circuit, sim_backend, shots=shots)
job = sim_backend.run(transpile(circuit, sim_backend), shots=shots)
result = job.result()

counts = result.get_counts(circuit)
Expand Down
4 changes: 2 additions & 2 deletions examples/python/load_qasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""Example on how to load a file into a QuantumCircuit."""

from qiskit import QuantumCircuit
from qiskit import execute, BasicAer
from qiskit import BasicAer

circ = QuantumCircuit.from_qasm_file("examples/qasm/entangled_registers.qasm")
print(circ)
Expand All @@ -23,7 +23,7 @@


# Compile and run the Quantum circuit on a local simulator backend
job_sim = execute(circ, sim_backend)
job_sim = sim_backend.run(circ)
sim_result = job_sim.result()

# Show the results
Expand Down
4 changes: 2 additions & 2 deletions examples/python/qft.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import math
from qiskit import QuantumCircuit
from qiskit import execute, BasicAer
from qiskit import transpile, BasicAer


###############################################################
Expand Down Expand Up @@ -68,7 +68,7 @@ def qft(circ, n):

print("Qasm simulator")
sim_backend = BasicAer.get_backend("qasm_simulator")
job = execute([qft3, qft4, qft5], sim_backend, shots=1024)
job = sim_backend.run(transpile([qft3, qft4, qft5], sim_backend), shots=1024)
result = job.result()
print(result.get_counts(qft3))
print(result.get_counts(qft4))
Expand Down
6 changes: 3 additions & 3 deletions examples/python/rippleadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit import BasicAer
from qiskit import execute
from qiskit import transpile

###############################################################
# Set the backend name and coupling map.
Expand Down Expand Up @@ -101,12 +101,12 @@ def unmajority(p, a, b, c):
###############################################################

# First version: not mapped
job = execute(qc, backend=backend, coupling_map=None, shots=1024)
job = backend.run(transpile(qc, backend=backend, coupling_map=None), shots=1024)
result = job.result()
print(result.get_counts(qc))

# Second version: mapped to 2x8 array coupling graph
job = execute(qc, backend=backend, coupling_map=coupling_map, shots=1024)
job = backend.run(transpile(qc, basis_gates=["u", "cx"], coupling_map=coupling_map), shots=1024)
result = job.result()
print(result.get_counts(qc))

Expand Down
11 changes: 7 additions & 4 deletions examples/python/teleport.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit import BasicAer
from qiskit import execute
from qiskit import transpile

###############################################################
# Set the backend name and coupling map.
Expand Down Expand Up @@ -65,14 +65,17 @@

# First version: not mapped
initial_layout = {q[0]: 0, q[1]: 1, q[2]: 2}
job = execute(qc, backend=backend, coupling_map=None, shots=1024, initial_layout=initial_layout)
job = backend.run(
transpile(qc, backend=backend, coupling_map=None, initial_layout=initial_layout), shots=1024
)

result = job.result()
print(result.get_counts(qc))

# Second version: mapped to 2x8 array coupling graph
job = execute(
qc, backend=backend, coupling_map=coupling_map, shots=1024, initial_layout=initial_layout
job = backend.run(
transpile(qc, backend=backend, coupling_map=coupling_map, initial_layout=initial_layout),
shots=1024,
)
result = job.result()
print(result.get_counts(qc))
Expand Down
11 changes: 6 additions & 5 deletions examples/python/using_qiskit_terra_level_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# that they have been altered from the originals.

"""
Example showing how to use Qiskit-Terra at level 0 (novice).
Example showing how to use Qiskit at introduction level.
This example shows the most basic way to user Terra. It builds some circuits
and runs them on both the BasicAer (local Qiskit provider) or IBMQ (remote IBMQ provider).
This example shows the most basic way to use Qiskit. It builds some circuits
and runs them on both the BasicAer (local Qiskit provider) or IBM Quantum (remote IBM Quantum provider).
To control the compile parameters we have provided a transpile function which can be used
as a level 1 user.
Expand All @@ -23,7 +23,7 @@

# Import the Qiskit modules
from qiskit import QuantumCircuit
from qiskit import execute, BasicAer
from qiskit import transpile, BasicAer

# making first circuit: bell state
qc1 = QuantumCircuit(2, 2)
Expand All @@ -41,7 +41,8 @@
print(BasicAer.backends())

# running the job
job_sim = execute([qc1, qc2], BasicAer.get_backend("qasm_simulator"))
sim_backend = BasicAer.get_backend("qasm_simulator")
job_sim = sim_backend.run(transpile([qc1, qc2], sim_backend))
sim_result = job_sim.result()

# Show the results
Expand Down
2 changes: 0 additions & 2 deletions qiskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@

_config = _user_config.get_config()

from qiskit.execute_function import execute
from qiskit.compiler import transpile, assemble, schedule, sequence

from .version import __version__
Expand All @@ -78,7 +77,6 @@
"QuantumCircuit",
"QuantumRegister",
"assemble",
"execute",
"schedule",
"sequence",
"transpile",
Expand Down
Loading

0 comments on commit 1a027ac

Please sign in to comment.