-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Implement PhasedXZGate._unitary_ #4617
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,6 +199,22 @@ def test_from_matrix_close_unitary(unitary: np.ndarray): | |
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'unitary', | ||
[ | ||
cirq.testing.random_unitary(2), | ||
cirq.testing.random_unitary(2), | ||
cirq.testing.random_unitary(2), | ||
np.array([[0, 1], [1j, 0]]), | ||
], | ||
) | ||
def test_from_matrix_close_kraus(unitary: np.ndarray): | ||
gate = cirq.PhasedXZGate.from_matrix(unitary) | ||
kraus = cirq.kraus(gate) | ||
assert len(kraus) == 1 | ||
cirq.testing.assert_allclose_up_to_global_phase(kraus[0], unitary, atol=1e-8) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: is this tol too high for complex64. I would've expected only around 6-7 decimal digits of reliability. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was copy-pasted from other |
||
|
||
|
||
def test_protocols(): | ||
a = random.random() | ||
b = random.random() | ||
|
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.
Can we add another test that hits
cirq.unitary
as well ?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.
There is already a test of
cirq.unitary
: https://github.com/quantumlib/Cirq/blob/master/cirq-core/cirq/ops/phased_x_z_gate_test.py#L196. This worked by decomposition even without a_unitary_
implementation, but other protocols likecirq.kraus
didn't.