Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
14 changes: 13 additions & 1 deletion docs/tutorials/creating_and_manipulating_qbits.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@
"qbits.draw(radius=\"nearest\")"
]
},
{
"cell_type": "markdown",
"source": "The `draw` method also supports an `interactive` mode for 3D lattices. Passing `interactive=True` renders a rotatable, zoomable Plotly figure that stays interactive in the documentation website.",
"metadata": {}
},
{
"cell_type": "code",
"source": "qbits = qse.Qbits(cell=np.eye(3), positions=np.zeros((1, 3)))\nqbits = qbits.repeat((4, 4, 4))\nqbits.draw(radius=\"nearest\", interactive=True)",
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -275,4 +287,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ docs = [
"ipywidgets",
"ipympl",
"pulser", # required for creating the docs
"qiskit"
"qiskit",
"plotly",
]

[dependency-groups]
Expand Down
38 changes: 29 additions & 9 deletions qse/qbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from qse.cell import Cell
from qse.operator import Operator, Operators
from qse.qbit import Qbit
from qse.vis import draw_qbits
from qse.vis import draw_3d_qbits_interactive, draw_qbits


class Qbits:
Expand Down Expand Up @@ -540,6 +540,8 @@ def draw(
colouring=None,
units=None,
equal_aspect=True,
alpha_min=0.0,
interactive=False,
):
"""
Visualize the positions of a set of qubits.
Expand All @@ -563,19 +565,37 @@ def draw(
equal_aspect : bool, optional
Whether to have the same scaling for the axes.
Defaults to True.
alpha_min : float, optional
Minimum alpha for bond opacity. Bond alphas are linearly rescaled
from (alpha_min, 1), where 1 is the shortest bond and alpha_min
is the longest. Defaults to 0.0.
interactive : bool, optional
If True, render an interactive 3D Plotly figure (3D lattices only).
Requires ``plotly`` to be installed. Defaults to False.

See Also
--------
qse.draw
"""
draw_qbits(
self,
radius=radius,
show_labels=show_labels,
colouring=colouring,
units=units,
equal_aspect=equal_aspect,
)
if interactive:
draw_3d_qbits_interactive(
self,
radius=radius,
show_labels=show_labels,
colouring=colouring,
units=units,
alpha_min=alpha_min,
)
else:
return draw_qbits(
self,
radius=radius,
show_labels=show_labels,
colouring=colouring,
units=units,
equal_aspect=equal_aspect,
alpha_min=alpha_min,
)

def repeat(self, rep):
"""Create new repeated qbits object.
Expand Down
3 changes: 2 additions & 1 deletion qse/vis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
"bar",
"draw_amp_and_det",
"draw_qbits",
"draw_3d_qbits_interactive",
"draw_signal",
"view_matrix",
"qse_green",
"qse_red",
]
from qse.vis.colours import qse_green, qse_red
from qse.vis.qbits import draw_qbits
from qse.vis.qbits import draw_3d_qbits_interactive, draw_qbits
from qse.vis.signal import draw_amp_and_det, draw_signal
from qse.vis.visualise import bar, view_matrix
Loading
Loading