-
Notifications
You must be signed in to change notification settings - Fork 982
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
Channel matrix #4146
Channel matrix #4146
Conversation
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.
One formatting comment before diving into implementation.
|
||
@pytest.mark.parametrize( | ||
'kraus_operators, expected_channel_matrix', | ||
( |
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 looks like these parameterizations are reused across tests. Could you define constants for them?
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.
Most of the repeated constants were the Kraus operators of the completely depolarizing channel. I changed the code to use a short cirq expression to generate those instead of hardcoding. I also changed Kraus operators in another test case. The remaining constants are either different or very short (e.g. np.eye(2)
). This cuts away almost all duplication (the Choi and channel matrices were of course different all along) while keeping all inputs local so the reader does not need to scroll to examine correctness.
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.
No implementation worries, but one more formatting comment on the tests.
), | ||
), | ||
) | ||
def test_kraus_to_channel_matrix(kraus_operators, expected_channel_matrix): |
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.
To avoid confusion, expected_channel_matrix
should not be reused here since it's already the name of a function in this file.
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.
Renamed functions to use verbs in the name.
Utility for computing perhaps the most obvious representation of quantum channels: as a matrix.
This representation allows channel application via simple matrix multiplication (where input and output density operators are vectorized) and efficient computation of entanglement fidelity (follow-up).