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

Call cirq.testing.assert_equivalent_repr for cirq.SingleQubitCliffordGate and cirq.CliffordTableau #5664

Merged
merged 13 commits into from Jul 7, 2022

Conversation

vtomole
Copy link
Collaborator

@vtomole vtomole commented Jul 3, 2022

cirq.CliffordTableau is represented by rs, xs and zs yet these can't be passed into the __init__ but are instead calculated and/or set in the class. This PR adds xs, xs, and zs as Optional arguments so that the CliffordTableau can be reconstructed from the __repr__.

Fixes: #5641

@CirqBot CirqBot added the size: M 50< lines changed <250 label Jul 3, 2022
@vtomole vtomole marked this pull request as ready for review July 3, 2022 05:16
@vtomole vtomole requested review from a team and cduck as code owners July 3, 2022 05:16
cirq-core/cirq/ops/clifford_gate.py Outdated Show resolved Hide resolved
cirq-core/cirq/qis/clifford_tableau.py Outdated Show resolved Hide resolved
@vtomole vtomole requested a review from viathor July 7, 2022 19:21
Copy link
Collaborator

@viathor viathor left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@@ -55,6 +55,21 @@ def test_tableau_initial_state_string(num_qubits):
assert splitted_represent_string[n] == expected_string


def test_tableau_ivalid_initial_state():
Copy link
Collaborator

Choose a reason for hiding this comment

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

ivalid -> invalid

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

else:
raise ValueError(
f"The value you passed for rs is not the correct shape and/or type. "
f"Please confirm that it's 1 row, of even length and of type bool."
Copy link
Collaborator

Choose a reason for hiding this comment

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

It isn't enough for the length to be even. It actually needs to be twice the number of qubits. Suggestion:

f"Please ensure that it's a single row with two bool entries per qubit."

(The message in your other exception, raised on line 197, already reflects this.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@vtomole vtomole added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 7, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 7, 2022
@CirqBot CirqBot merged commit 11726fc into quantumlib:master Jul 7, 2022
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jul 7, 2022
@vtomole vtomole deleted the clifford_repr branch July 7, 2022 23:11
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…ordGate` and `cirq.CliffordTableau` (quantumlib#5664)

`cirq.CliffordTableau` is represented by `rs`, `xs` and `zs` yet these can't be passed into the `__init__` but are instead calculated and/or set in the class. This PR adds `xs`, `xs`, and `zs` as `Optional` arguments so that the `CliffordTableau` can be reconstructed from the `__repr__`.

Fixes: quantumlib#5641
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eval(repr(op)) fails for cirq.SingleQubitCliffordGate.
3 participants