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

Serialize SingleQubitCliffordGate #4421

Merged
merged 8 commits into from Aug 24, 2021
Merged

Serialize SingleQubitCliffordGate #4421

merged 8 commits into from Aug 24, 2021

Conversation

ishmum123
Copy link
Contributor

@ishmum123 ishmum123 commented Aug 12, 2021

Closes #3980

I tried to mimic the PauliString Class for serialization -

def _json_dict_(self) -> Dict[str, Any]:
return {
'cirq_type': self.__class__.__name__,
# JSON requires mappings to have string keys.
'qubit_pauli_map': list(self._qubit_pauli_map.items()),
'coefficient': self.coefficient,
}
@classmethod
def _from_json_dict_(cls, qubit_pauli_map, coefficient, **kwargs):
return cls(qubit_pauli_map=dict(qubit_pauli_map), coefficient=coefficient)

@ishmum123 ishmum123 requested review from cduck, vtomole and a team as code owners August 12, 2021 02:59
@google-cla
Copy link

google-cla bot commented Aug 12, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Aug 12, 2021
@ishmum123
Copy link
Contributor Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes Makes googlebot stop complaining. and removed cla: no labels Aug 12, 2021
@CirqBot CirqBot added the size: XL lines changed >1000 label Aug 12, 2021
@MichaelBroughton MichaelBroughton removed the size: XL lines changed >1000 label Aug 12, 2021
@CirqBot CirqBot added the size: S 10< lines changed <50 label Aug 12, 2021
@ishmum123
Copy link
Contributor Author

@MichaelBroughton I am very sorry about the force pushes. My branch was showing a random error and incompatibility with the master

@@ -436,6 +436,18 @@ def __repr__(self) -> str:
f'Y:{y_sign}{y.to!s}, Z:{z_sign}{z.to!s})'
)

@classmethod
def _from_json_dict_(cls, _rotation_map, _inverse_map, **kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if it would be worth having a (parameterized) test in clifford_gate_test.py to run through all the single qubit clifford gates and do the round trip to json and from json and make sure they are equal. This might be a little bit higher confidence than having the single example in json_test_data, especially since that example has an empty inverse map.

Otherwise seems good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you please check now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dstrain115 ping!

@google-cla
Copy link

google-cla bot commented Aug 14, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes Makes googlebot stop complaining. labels Aug 14, 2021
@google-cla google-cla bot added cla: yes Makes googlebot stop complaining. and removed cla: no labels Aug 14, 2021
@ishmum123
Copy link
Contributor Author

@MichaelBroughton can you please check if this is okay?

Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

LGTM

@MichaelBroughton MichaelBroughton added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Aug 24, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Aug 24, 2021
@CirqBot CirqBot merged commit 58cda7a into quantumlib:master Aug 24, 2021
@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 Aug 24, 2021
@ishmum123 ishmum123 deleted the serialization branch August 25, 2021 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining. size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SingleQubitCliffordGate does not properly serialize to JSON
4 participants