Skip to content

Commit

Permalink
Daily rc sync to master (PennyLaneAI#4988)
Browse files Browse the repository at this point in the history
Automatic sync from the release candidate to master during a feature
freeze.

---------

Co-authored-by: Christina Lee <[email protected]>
Co-authored-by: Pieter Eendebak <[email protected]>
Co-authored-by: Christina Lee <[email protected]>
Co-authored-by: lillian542 <[email protected]>
Co-authored-by: lillian542 <[email protected]>
Co-authored-by: Tom Bromley <[email protected]>
Co-authored-by: Isaac De Vlugt <[email protected]>
Co-authored-by: Josh Izaac <[email protected]>
Co-authored-by: GitHub Actions Bot <>
  • Loading branch information
9 people committed Jan 4, 2024
1 parent 7242786 commit f6a7375
Show file tree
Hide file tree
Showing 13 changed files with 202 additions and 149 deletions.
Binary file modified doc/_static/draw_mpl/mid_measure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_static/tape_mpl/decimals.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_static/tape_mpl/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_static/tape_mpl/mid_measure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_static/tape_mpl/postprocessing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_static/tape_mpl/rcparams.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_static/tape_mpl/show_all_wires.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_static/tape_mpl/sketch_style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_static/tape_mpl/wire_order.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_static/tape_mpl/wires_labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
330 changes: 184 additions & 146 deletions doc/releases/changelog-0.34.0.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pennylane/drawer/mpldrawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ def __init__(self, n_layers, n_wires, c_wires=0, wire_options=None, figsize=None
## Creating figure and ax

if figsize is None:
figsize = (self.n_layers + 3, self.n_wires + self._cwire_scaling * c_wires + 1.5)
figheight = self.n_wires + self._cwire_scaling * c_wires + 1 + 0.5 * (c_wires > 0)
figsize = (self.n_layers + 3, figheight)

if fig is None:
self._fig = plt.figure(figsize=figsize)
Expand All @@ -282,7 +283,7 @@ def __init__(self, n_layers, n_wires, c_wires=0, wire_options=None, figsize=None
self._ax = self._fig.add_axes(
[0, 0, 1, 1],
xlim=(-2, self.n_layers + 1),
ylim=(-1, self.n_wires + self._cwire_scaling * c_wires + 0.5),
ylim=(-1, self.n_wires + self._cwire_scaling * c_wires + 0.5 * (c_wires > 0)),
xticks=[],
yticks=[],
)
Expand Down
16 changes: 15 additions & 1 deletion tests/drawer/test_mpldrawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_figsize_wires(self, n_wires, n_layers):
drawer = MPLDrawer(n_wires=n_wires, n_layers=n_layers)

assert drawer.fig.get_figwidth() == (n_layers + 3)
assert drawer.fig.get_figheight() == (n_wires + 1.5)
assert drawer.fig.get_figheight() == (n_wires + 1)

drawer = MPLDrawer(n_wires=n_wires, n_layers=n_layers)

Expand All @@ -55,6 +55,20 @@ def test_figsize_wires(self, n_wires, n_layers):
assert line.get_ydata() == (wire, wire)
plt.close()

def test_figsize_classical_wires(self):
"""Test the figsize is correct if classical wires are present."""
n_wires = 4
c_wires = 4
n_layers = 1

drawer = MPLDrawer(n_wires=n_wires, n_layers=n_layers, c_wires=c_wires)

assert drawer.fig.get_figheight() == n_wires + 1 + 0.25 * 4 + 0.5
assert drawer.fig.get_figwidth() == n_layers + 3

assert drawer.ax.get_xlim() == (-2, 2)
assert drawer.ax.get_ylim() == (n_wires + 0.25 * 4 + 0.5, -1)

def test_customfigsize(self):
"""Tests a custom figsize alters the size"""

Expand Down

0 comments on commit f6a7375

Please sign in to comment.