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

Removed Deprecation of Qiskit Jupyter Tools #11539

Closed
wants to merge 2 commits into from
Closed
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
23 changes: 1 addition & 22 deletions qiskit/tools/jupyter/jupyter_magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@

import time
import threading
from IPython import get_ipython
from IPython.display import display
from IPython.core import magic_arguments
from IPython.core.magic import cell_magic, line_magic, Magics, magics_class, register_line_magic
from IPython.core.magic import cell_magic, line_magic, Magics, magics_class

from qiskit.utils import optionals as _optionals
from qiskit.utils.deprecation import deprecate_func
import qiskit
from qiskit.tools.events.progressbar import TextProgressBar
from .progressbar import HTMLProgressBar
from .library import circuit_library_widget


def _html_checker(job_var, interval, status, header, _interval_set=False):
Expand Down Expand Up @@ -170,21 +167,3 @@ def qiskit_progress_bar(self, line="", cell=None): # pylint: disable=unused-arg
raise qiskit.QiskitError("Invalid progress bar type.")

return pbar


if _optionals.HAS_MATPLOTLIB and get_ipython():

@register_line_magic
@deprecate_func(
since="0.25.0",
additional_msg="This was originally only for internal documentation and is no longer used.",
)
def circuit_library_info(circuit: qiskit.QuantumCircuit) -> None:
"""Displays library information for a quantum circuit.

Args:
circuit: Input quantum circuit.
"""
shell = get_ipython()
circ = shell.ev(circuit)
circuit_library_widget(circ)
152 changes: 0 additions & 152 deletions qiskit/tools/jupyter/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@

"""A circuit library widget module"""

import ipywidgets as wid
from IPython.display import display
from qiskit import QuantumCircuit
from qiskit.utils import optionals as _optionals
from qiskit.utils.deprecation import deprecate_func


@_optionals.HAS_MATPLOTLIB.require_in_call
Expand All @@ -38,152 +35,3 @@ def _generate_circuit_library_visualization(circuit: QuantumCircuit):
)
plt.tight_layout()
plt.show()


@deprecate_func(
since="0.25.0",
additional_msg="This is unused by Qiskit, and no replacement will be publicly provided.",
package_name="qiskit-terra",
)
def circuit_data_table(circuit: QuantumCircuit) -> wid.HTML:
"""Create a HTML table widget for a given quantum circuit.

Args:
circuit: Input quantum circuit.

Returns:
Output widget.
"""

circuit = circuit.decompose()
ops = circuit.count_ops()
num_nl = circuit.num_nonlocal_gates()

html = "<table>"
html += """<style>
table {
font-family: "IBM Plex Sans", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
border-left: 2px solid #212121;
}

th {
text-align: left;
padding: 5px 5px 5px 5px;
width: 100%;
background-color: #988AFC;
color: #fff;
font-size: 14px;
border-left: 2px solid #988AFC;
}

td {
text-align: left;
padding: 5px 5px 5px 5px;
width: 100%;
font-size: 12px;
font-weight: medium;
}

tr:nth-child(even) {background-color: #f6f6f6;}
</style>"""
html += f"<tr><th>{circuit.name}</th><th></tr>"
html += f"<tr><td>Width</td><td>{circuit.width()}</td></tr>"
html += f"<tr><td>Depth</td><td>{circuit.depth()}</td></tr>"
html += f"<tr><td>Total Gates</td><td>{sum(ops.values())}</td></tr>"
html += f"<tr><td>Non-local Gates</td><td>{num_nl}</td></tr>"
html += "</table>"

out_wid = wid.HTML(html)
return out_wid


head_style = (
"font-family: IBM Plex Sans, Arial, Helvetica, sans-serif;"
" font-size: 20px; font-weight: medium;"
)

property_label = wid.HTML(
f"<p style='{head_style}'>Circuit Properties</p>",
layout=wid.Layout(margin="0px 0px 10px 0px"),
)


@deprecate_func(
since="0.25.0",
additional_msg="This is unused by Qiskit, and no replacement will be publicly provided.",
package_name="qiskit-terra",
)
def properties_widget(circuit: QuantumCircuit) -> wid.VBox:
"""Create a HTML table widget with header for a given quantum circuit.

Args:
circuit: Input quantum circuit.

Returns:
Output widget.
"""
properties = wid.VBox(
children=[property_label, circuit_data_table(circuit)],
layout=wid.Layout(width="40%", height="auto"),
)
return properties


@deprecate_func(
since="0.25.0",
additional_msg="This is unused by Qiskit, and no replacement will be publicly provided.",
package_name="qiskit-terra",
)
def circuit_diagram_widget() -> wid.Box:
"""Create a circuit diagram widget.

Returns:
Output widget.
"""
# The max circuit height corresponds to a 20Q circuit with flat
# classical register.
top_out = wid.Output(
layout=wid.Layout(
width="100%",
height="auto",
max_height="1000px",
overflow="hidden scroll",
)
)

top = wid.Box(children=[top_out], layout=wid.Layout(width="100%", height="auto"))

return top


@deprecate_func(
since="0.25.0",
additional_msg="This is unused by Qiskit, and no replacement will be publicly provided.",
package_name="qiskit-terra",
)
def circuit_library_widget(circuit: QuantumCircuit) -> None:
"""Create a circuit library widget.

Args:
circuit: Input quantum circuit.
"""
sep_length = str(min(20, 495))

# The separator widget
sep = wid.HTML(
f"<div style='border-left: 3px solid #212121;height: {sep_length}px;'></div>",
layout=wid.Layout(height="auto", max_height="495px", margin="40px 0px 0px 20px"),
)
bottom = wid.HBox(
children=[properties_widget(circuit), sep],
layout=wid.Layout(max_height="550px", height="auto"),
)

top = circuit_diagram_widget()

with top.children[0]:
display(circuit.decompose().draw(output="mpl"))

display(wid.VBox(children=[top, bottom], layout=wid.Layout(width="100%", height="auto")))
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
upgrade:
- |
Removed deprecated qiskit jupyter tools from qiskit/tools.