Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryoris committed Oct 25, 2024
1 parent dbfe5f0 commit 2b84ece
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions qiskit/circuit/library/n_local/efficient_su2.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def efficient_su2(
.. plot::
:include-source:
from qiskit.circuit.library import efficient_su2
circuit = efficient_su2(3, reps=1)
circuit.draw("mpl")
Expand All @@ -82,6 +84,7 @@ def efficient_su2(
.. plot::
:include-source:
:context:
circuit = efficient_su2(4, su2_gates=["rx", "y"], entanglement="circular", reps=1)
circuit.draw("mpl")
Expand Down
3 changes: 3 additions & 0 deletions qiskit/circuit/library/n_local/excitation_preserving.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def excitation_preserving(
.. plot::
:include-source:
from qiskit.circuit.library import excitation_preserving
ansatz = excitation_preserving(3, reps=1, insert_barriers=True, entanglement="linear")
ansatz.draw("mpl")
Expand All @@ -81,6 +83,7 @@ def excitation_preserving(
.. plot::
:include-source:
:context:
ansatz = excitation_preserving(3, reps=1, mode="fsim", entanglement=[[0, 2]])
ansatz.draw("mpl")
Expand Down
10 changes: 8 additions & 2 deletions qiskit/circuit/library/n_local/n_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def n_local(
.. plot::
:include-source:
from qiskit.circuit.library import n_local
circuit = n_local(3, "ry", "cx", "linear", reps=2, insert_barriers=True)
circuit.draw("mpl")
Expand All @@ -156,14 +158,16 @@ def n_local(
.. plot::
:include-source:
:context:
circuit = n_local(3, ["ry", "rz"], "cz", 'full', reps=1, insert_barriers=True)
circuit = n_local(3, ["ry", "rz"], "cz", "full", reps=1, insert_barriers=True)
circuit.draw("mpl")
To omit rotation or entanglement layers, the block can be set to an empty list:
.. plot::
:include-source:
:context:
circuit = n_local(4, [], "cry", reps=2)
circuit.draw("mpl")
Expand All @@ -172,6 +176,7 @@ def n_local(
.. plot::
:include-source:
:context:
entangler_map = [[0, 1], [2, 0]]
circuit = n_local(3, "x", "crx", entangler_map, reps=2)
Expand All @@ -183,8 +188,9 @@ def n_local(
.. plot:
:include-source:
:context:
def entanglement(layer_index: int) -> list[list[int]]:
def entanglement(layer_index):
if layer_index % 2 == 0:
return [[0, 1], [0, 2]]
return [[1, 2]]
Expand Down
5 changes: 5 additions & 0 deletions qiskit/circuit/library/n_local/real_amplitudes.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,28 @@ def real_amplitudes(
.. plot::
:include-source:
from qiskit.circuit.library import real_amplitudes
ansatz = real_amplitudes(3, reps=2) # create the circuit on 3 qubits
ansatz.draw("mpl")
.. plot::
:include-source:
:context:
ansatz = real_amplitudes(3, entanglement="full", reps=2) # it is the same unitary as above
ansatz.draw("mpl")
.. plot::
:include-source:
:context:
ansatz = real_amplitudes(3, entanglement="linear", reps=2, insert_barriers=True)
ansatz.draw("mpl")
.. plot::
:include-source:
:context:
ansatz = real_amplitudes(4, reps=2, entanglement=[[0,3], [0,2]], skip_unentangled_qubits=True)
ansatz.draw("mpl")
Expand Down

0 comments on commit 2b84ece

Please sign in to comment.