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

draw a qnode with MPL #1803

Merged
merged 32 commits into from
Nov 18, 2021
Merged

draw a qnode with MPL #1803

merged 32 commits into from
Nov 18, 2021

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Oct 25, 2021

This PR is dependent on #1787

It adds a transform that draws a qnode with matplotlib.

@albi3ro albi3ro added the WIP 🚧 Work-in-progress label Oct 25, 2021
@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Oct 25, 2021

Codecov Report

Merging #1803 (23f3b66) into master (72c7b1d) will increase coverage by 7.23%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1803      +/-   ##
==========================================
+ Coverage   91.59%   98.83%   +7.23%     
==========================================
  Files         222      222              
  Lines       16972    16979       +7     
==========================================
+ Hits        15546    16781    +1235     
+ Misses       1426      198    -1228     
Impacted Files Coverage Δ
pennylane/__init__.py 100.00% <ø> (ø)
pennylane/circuit_drawer/__init__.py 100.00% <100.00%> (ø)
pennylane/circuit_drawer/tape_mpl.py 100.00% <100.00%> (ø)
pennylane/transforms/__init__.py 100.00% <100.00%> (ø)
pennylane/transforms/draw.py 100.00% <100.00%> (ø)
pennylane/circuit_drawer/mpldrawer.py 98.38% <0.00%> (-1.62%) ⬇️
pennylane/devices/default_qubit.py 100.00% <0.00%> (+0.40%) ⬆️
pennylane/utils.py 97.94% <0.00%> (+0.68%) ⬆️
pennylane/templates/embeddings/amplitude.py 98.03% <0.00%> (+1.96%) ⬆️
pennylane/gradients/vjp.py 100.00% <0.00%> (+3.12%) ⬆️
... and 31 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72c7b1d...23f3b66. Read the comment docs.

@albi3ro albi3ro changed the title [WIP] draw a qnode with MPL draw a qnode with MPL Oct 27, 2021
Base automatically changed from mpldrawer_integration to master November 11, 2021 16:40
@albi3ro albi3ro removed the WIP 🚧 Work-in-progress label Nov 15, 2021
Copy link
Contributor

@Jaybsoni Jaybsoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Can't wait to use this functionality !

tests/circuit_drawer/test_mpldrawer.py Show resolved Hide resolved
doc/releases/changelog-dev.md Show resolved Hide resolved

folder = pathlib.Path(__file__).parent

def main_example(circuit):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very small thing but maybe we could pass the parameters of the circuit as an argument into each of the functions as well, that way, if in the future the circuit is changed for some reason, the parameters can all be changed simultaneously without changing each line

pennylane/transforms/draw.py Outdated Show resolved Hide resolved
pennylane/transforms/draw.py Outdated Show resolved Hide resolved
pennylane/transforms/draw.py Outdated Show resolved Hide resolved
tests/transforms/test_draw_mpl.py Show resolved Hide resolved

assert len(ax.texts) == 4 # three wire labels and one gate label
assert ax.texts[0].get_text() == "2"
assert ax.texts[1].get_text() == "a"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a random thought, maybe as a separate feature, could we assign a single label to a group of wires, lets say for example we have 5 wires, 2 are ancillary and the remaining 3 constitute a state $\psi$

Comment on lines 194 to 196
.. UsageDetails::

**Decimals:**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to indent everything below UsageDetails! Otherwise Sphinx won't consider it part of UsageDetails:

@albi3ro albi3ro merged commit 33f1716 into master Nov 18, 2021
@albi3ro albi3ro deleted the mpldrawer_qnode branch November 18, 2021 16:46
@antalszava
Copy link
Contributor

[sc-9615]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants