-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add iSWAP and CPhase gates #45
Conversation
Codecov Report
@@ Coverage Diff @@
## master #45 +/- ##
==========================================
+ Coverage 99.03% 99.07% +0.03%
==========================================
Files 8 8
Lines 312 324 +12
==========================================
+ Hits 309 321 +12
Misses 3 3
Continue to review full report at Codecov.
|
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 from my end Theo 👍
Do we have tests for the plugin custom ops?
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.
Thanks @thisac. I found a few obvious typos and have some questions about the tests.
pennylane_cirq/ops.py
Outdated
[[1, 0, 0, 0], | ||
[0, 1, 0, 0], | ||
[0, 0, 1, 0], | ||
[0, 0, 0, e^{i\phi]] |
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.
[0, 0, 0, e^{i\phi]] | |
[0, 0, 0, e^{i\phi}]] |
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.
Doesn't the bmatrix
need newlines?
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.
You're completely right. This is a very ugly mix of Python and Latex. 😆
tests/test_native_ops.py
Outdated
@pytest.mark.parametrize("input", | ||
[ | ||
[1, 0, 0, 0], | ||
[0, 1, 0, 0], | ||
[0, 0, 1, 0], | ||
[0, 0, 0, 1], | ||
] | ||
) |
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.
I struggled to understand this. If the device has two wires, then shouldn't the underlying pure state have shape (2,2)
?
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.
It should have shape (4,)
, right? For the different bitstrings 00
, 01
, 10
and 11
. Which is what this is (each row corresponding to an input). 🤔
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.
Aha, got it! the pytest parametrize format looks exactly like a 2d array 😆
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.
Might be good to test on superposition states as well
Thanks @co9olguy for the review. Too many 🤦s in this one though, but I fixed the typos and the gate application order, and also tried to make the parametrization less confusing (adding a few more interesting states, and avoiding it looking like the identity). |
np.array([0, 0, 1, 0]), | ||
np.array([0, 1, 0, 1]) / np.sqrt(2), | ||
np.array([0, 0, 0, 1]), | ||
np.array([2, 1, 2, 1]) / np.sqrt(10), |
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.
💯
This PR adds the iSWAP and CPhase gates from Cirq to
ops.py
.