-
Notifications
You must be signed in to change notification settings - Fork 575
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
Device tests run in tape #1026
Device tests run in tape #1026
Conversation
Hello. You may have forgotten to update the changelog!
|
Codecov Report
@@ Coverage Diff @@
## master #1026 +/- ##
==========================================
+ Coverage 95.44% 97.93% +2.49%
==========================================
Files 153 153
Lines 11392 11392
==========================================
+ Hits 10873 11157 +284
+ Misses 519 235 -284
Continue to review full report at Codecov.
|
@@ -46,7 +46,7 @@ | |||
"CSWAP": qml.CSWAP(wires=[0, 1, 2]), | |||
"CZ": qml.CZ(wires=[0, 1]), | |||
"CY": qml.CY(wires=[0, 1]), | |||
"DiagonalQubitUnitary": qml.DiagonalQubitUnitary(np.eye(2), wires=[0]), | |||
"DiagonalQubitUnitary": qml.DiagonalQubitUnitary(np.array([1, 1]), wires=[0]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 Looks great Antal!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @antalszava! 🚀
pennylane/devices/tests/conftest.py
Outdated
@pytest.fixture | ||
def in_tape_mode(): | ||
"""Run the test in tape mode""" | ||
qml.enable_tape() | ||
yield | ||
qml.disable_tape() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ever used in devices/tests
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, good catch! Removed.
@@ -106,7 +106,7 @@ def circuit(theta, phi): | |||
assert np.allclose(qnode(theta, phi), qnode_def(theta, phi), atol=tol(dev.analytic)) | |||
assert np.allclose(grad(theta, phi), grad_def(theta, phi), atol=tol(dev.analytic)) | |||
|
|||
@pytest.mark.parametrize("ret", [qml.expval, qml.var]) | |||
@pytest.mark.parametrize("ret", ["expval", "var"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? Did it not work before or is this just better/safer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tape mode was activated after ret
got its value, so non-tape qml.expval
and qml.var
were pulled in.
Context:
The device test suite runs in tape mode.
Description of the Change:
conftest.py
file of the device test suiteqml.expval
) in the test functions such that the tape version can also be fetched