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

Bugfix: draw template with matrix parameter #1917

Merged
merged 2 commits into from
Nov 19, 2021
Merged

Bugfix: draw template with matrix parameter #1917

merged 2 commits into from
Nov 19, 2021

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Nov 19, 2021

Bugfix for Issue #1916

Due to the new QNode expansion settings, the qnode tape has unexpanded templates, which the current text circuit drawer was unable to handle. This bugfix generalizes the treatment of matrix parameters.

This code was previously raising an error:

import pennylane as qml
from pennylane import numpy as np

dev = qml.device('default.qubit', wires = 1)

@qml.qnode(dev)
def circuit():
    qml.AmplitudeEmbedding(np.array([0,1]), wires=0)
    return qml.state()
                        
print(qml.draw(circuit)())

But now gives:

 0: ──AmplitudeEmbedding(M0)──┤ State 
M0 =
[0.+0.j 1.+0.j]

@albi3ro albi3ro added the bug 🐛 Something isn't working label Nov 19, 2021
@@ -259,7 +259,8 @@

<h3>Bug fixes</h3>

* `qml.CSWAP` and `qml.CRot` now define `control_wires`, and `qml.SWAP`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line was from a merge remnant and the actual full entry is below, so I tidied it up.

@codecov
Copy link

codecov bot commented Nov 19, 2021

Codecov Report

Merging #1917 (64de6b4) into master (c631726) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1917   +/-   ##
=======================================
  Coverage   98.83%   98.83%           
=======================================
  Files         222      222           
  Lines       16979    16979           
=======================================
  Hits        16781    16781           
  Misses        198      198           
Impacted Files Coverage Δ
...ennylane/circuit_drawer/representation_resolver.py 99.36% <100.00%> (ø)

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 c631726...64de6b4. Read the comment docs.

@KetpuntoG KetpuntoG merged commit 88d15ff into master Nov 19, 2021
@KetpuntoG KetpuntoG deleted the draw_bugfix branch November 19, 2021 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants