From d5e1a948b0417006dc5024331e644749b3508fd3 Mon Sep 17 00:00:00 2001 From: albi3ro Date: Thu, 31 Mar 2022 12:00:21 -0400 Subject: [PATCH 1/5] move draw and draw_mpl to drawer module --- doc/code/qml_drawer.rst | 18 +++++++----------- doc/releases/changelog-dev.md | 3 +++ pennylane/__init__.py | 1 + pennylane/drawer/__init__.py | 5 ++--- pennylane/{transforms => drawer}/draw.py | 3 ++- pennylane/transforms/__init__.py | 3 --- tests/{transforms => drawer}/test_draw.py | 0 tests/{transforms => drawer}/test_draw_mpl.py | 0 8 files changed, 15 insertions(+), 18 deletions(-) rename pennylane/{transforms => drawer}/draw.py (97%) rename tests/{transforms => drawer}/test_draw.py (100%) rename tests/{transforms => drawer}/test_draw_mpl.py (100%) diff --git a/doc/code/qml_drawer.rst b/doc/code/qml_drawer.rst index c61fdc887cf..ddffc0ef5b4 100644 --- a/doc/code/qml_drawer.rst +++ b/doc/code/qml_drawer.rst @@ -6,6 +6,13 @@ of circuits. .. currentmodule:: pennylane.drawer +.. automodapi:: pennylane.drawer + :no-heading: + :no-inheritance-diagram: + :no-inherited-members: + :skip: available_styles + :skip: use_style + Styling Matplotlib Circuit Graphics ----------------------------------- @@ -50,14 +57,3 @@ Currently Available Styles +-----+-----+-----+ +|bws|+|bwd|+|def|+ +-----+-----+-----+ - - -Developer Methods ------------------ - -.. automodapi:: pennylane.drawer - :no-heading: - :no-inheritance-diagram: - :no-inherited-members: - :skip: available_styles - :skip: use_style diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index da89fd3ddcf..ae263278682 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -200,6 +200,9 @@ * Circuit cutting now performs expansion to search for wire cuts in contained operations or tapes. [(#2340)](https://github.com/PennyLaneAI/pennylane/pull/2340) +* The `qml.draw` and `qml.draw_mpl` transforms are now located in the `drawer` module. They can still be + accessed via top-level `qml` namespace. +

Deprecations

Breaking changes

diff --git a/pennylane/__init__.py b/pennylane/__init__.py index f10c611a798..c5a6d241431 100644 --- a/pennylane/__init__.py +++ b/pennylane/__init__.py @@ -39,6 +39,7 @@ from pennylane.about import about from pennylane.circuit_graph import CircuitGraph from pennylane.configuration import Configuration +from pennylane.drawer import draw, draw_mpl from pennylane.tracker import Tracker from pennylane.io import * from pennylane.measurements import density_matrix, measure, expval, probs, sample, state, var diff --git a/pennylane/drawer/__init__.py b/pennylane/drawer/__init__.py index 24c3211a7de..fe098b5666b 100644 --- a/pennylane/drawer/__init__.py +++ b/pennylane/drawer/__init__.py @@ -14,15 +14,14 @@ """ This module provides the circuit drawing functionality used to display circuits visually. -.. currentmodule:: pennylane.circuit_drawer +.. currentmodule:: pennylane.drawer .. autosummary:: :toctree: api """ +from .draw import draw, draw_mpl from .tape_text import tape_text from .tape_mpl import tape_mpl from .mpldrawer import MPLDrawer -from .drawable_layers import drawable_layers -from .utils import convert_wire_order from .style import available_styles, use_style diff --git a/pennylane/transforms/draw.py b/pennylane/drawer/draw.py similarity index 97% rename from pennylane/transforms/draw.py rename to pennylane/drawer/draw.py index 13b231eef5d..92f3ad98b42 100644 --- a/pennylane/transforms/draw.py +++ b/pennylane/drawer/draw.py @@ -18,7 +18,8 @@ """ from functools import wraps -from pennylane.drawer import tape_mpl, tape_text +from .tape_mpl import tape_mpl +from .tape_text import tape_text def draw( diff --git a/pennylane/transforms/__init__.py b/pennylane/transforms/__init__.py index ee757215000..b797a8e1ea4 100644 --- a/pennylane/transforms/__init__.py +++ b/pennylane/transforms/__init__.py @@ -32,8 +32,6 @@ ~transforms.classical_jacobian ~batch_params ~batch_input - ~draw - ~draw_mpl ~transforms.get_unitary_matrix ~metric_tensor ~adjoint_metric_tensor @@ -177,7 +175,6 @@ from .control import ControlledOperation, ctrl from .decompositions import zyz_decomposition, two_qubit_decomposition from .defer_measurements import defer_measurements -from .draw import draw, draw_mpl from .hamiltonian_expand import hamiltonian_expand from .measurement_grouping import measurement_grouping from .metric_tensor import metric_tensor diff --git a/tests/transforms/test_draw.py b/tests/drawer/test_draw.py similarity index 100% rename from tests/transforms/test_draw.py rename to tests/drawer/test_draw.py diff --git a/tests/transforms/test_draw_mpl.py b/tests/drawer/test_draw_mpl.py similarity index 100% rename from tests/transforms/test_draw_mpl.py rename to tests/drawer/test_draw_mpl.py From e6dc003dee2be038d21c2e3a5220ed252be8aa48 Mon Sep 17 00:00:00 2001 From: Christina Lee Date: Thu, 31 Mar 2022 12:07:13 -0400 Subject: [PATCH 2/5] Update doc/releases/changelog-dev.md --- doc/releases/changelog-dev.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index ae263278682..8fc0bc982f6 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -202,6 +202,7 @@ * The `qml.draw` and `qml.draw_mpl` transforms are now located in the `drawer` module. They can still be accessed via top-level `qml` namespace. + [(#2396)](https://github.com/PennyLaneAI/pennylane/pull/2396)

Deprecations

From b5895c3c232546cefbca66f10503a009795cc9a9 Mon Sep 17 00:00:00 2001 From: albi3ro Date: Thu, 31 Mar 2022 12:22:35 -0400 Subject: [PATCH 3/5] oops --- pennylane/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pennylane/__init__.py b/pennylane/__init__.py index c5a6d241431..05ace4a2a7d 100644 --- a/pennylane/__init__.py +++ b/pennylane/__init__.py @@ -59,8 +59,6 @@ batch_input, batch_transform, cut_circuit, - draw, - draw_mpl, ControlledOperation, compile, ctrl, From 542beb44bdb097d557173044f594f85a2900fe72 Mon Sep 17 00:00:00 2001 From: albi3ro Date: Thu, 31 Mar 2022 12:48:49 -0400 Subject: [PATCH 4/5] fix tests imports --- tests/drawer/test_draw.py | 2 +- tests/test_qnode.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/drawer/test_draw.py b/tests/drawer/test_draw.py index bf66fd10878..86a7ebb34f9 100644 --- a/tests/drawer/test_draw.py +++ b/tests/drawer/test_draw.py @@ -20,7 +20,7 @@ import pennylane as qml from pennylane import numpy as np -from pennylane.transforms import draw +from pennylane.drawer import draw @qml.qnode(qml.device("default.qubit", wires=(0, "a", 1.234))) diff --git a/tests/test_qnode.py b/tests/test_qnode.py index b7744cc12dc..bebdfd233e1 100644 --- a/tests/test_qnode.py +++ b/tests/test_qnode.py @@ -20,7 +20,6 @@ import pennylane as qml from pennylane import numpy as pnp from pennylane import qnode, QNode -from pennylane.transforms import draw from pennylane.tape import QuantumTape From 252dff761d02fea21bab70f1beb8ab87e9e84882 Mon Sep 17 00:00:00 2001 From: Christina Lee Date: Thu, 31 Mar 2022 15:15:41 -0400 Subject: [PATCH 5/5] Update doc/releases/changelog-dev.md Co-authored-by: antalszava --- doc/releases/changelog-dev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 8fc0bc982f6..6cf3119b986 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -201,7 +201,7 @@ [(#2340)](https://github.com/PennyLaneAI/pennylane/pull/2340) * The `qml.draw` and `qml.draw_mpl` transforms are now located in the `drawer` module. They can still be - accessed via top-level `qml` namespace. + accessed via the top-level `qml` namespace. [(#2396)](https://github.com/PennyLaneAI/pennylane/pull/2396)

Deprecations