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

Add json serialization to sweeps #5618

Merged
merged 14 commits into from
Jul 12, 2022
Merged

Add json serialization to sweeps #5618

merged 14 commits into from
Jul 12, 2022

Conversation

dabacon
Copy link
Collaborator

@dabacon dabacon commented Jun 25, 2022

Adds missing json serialization for sweep objects.

Verified

This commit was signed with the committer’s verified signature.
dabacon Dave Bacon
@dabacon dabacon requested review from a team, vtomole and cduck as code owners June 25, 2022 00:22
@dabacon dabacon requested a review from 95-martin-orion June 25, 2022 00:22
@CirqBot CirqBot added the size: M 50< lines changed <250 label Jun 25, 2022
Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

LGTM (% one concern, below). What is the expected use case for this?

@@ -196,6 +197,9 @@ def param_tuples(self) -> Iterator[Params]:
def __repr__(self) -> str:
return 'cirq.UnitSweep'

def _json_dict_(self) -> Dict[str, Any]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on the name, _Unit is a private class. Do we want it to be serializable?

If so, I think this needs a _from_json_dict_ classmethod.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This ends up being necessary in order to serialize UnitSweep. This is similar, I think to the Pauli singletons. My criteria was that with this PR it should serialize and deserialize cirq.UnitSweep correctly (should be UNIT_SWEEP btw), which it does. I think you can also use it to serialize and deserialize _Unit by going in and grabbing that class explicitly, but I don't know a way to stop this for this singleton pattern.

Copy link
Collaborator

Choose a reason for hiding this comment

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

SGTM. This can merge once the tests are sorted out.

dabacon added 4 commits June 27, 2022 21:45

Verified

This commit was signed with the committer’s verified signature.
dabacon Dave Bacon

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@dabacon
Copy link
Collaborator Author

dabacon commented Jul 7, 2022

Use case is that objects that set our context for experiments should be serializable.

dabacon added 2 commits July 7, 2022 13:55

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@dabacon
Copy link
Collaborator Author

dabacon commented Jul 12, 2022

Ugh bad merge fixing

dabacon added 3 commits July 12, 2022 19:37

Verified

This commit was signed with the committer’s verified signature.
dabacon Dave Bacon

Verified

This commit was signed with the committer’s verified signature.
dabacon Dave Bacon

Verified

This commit was signed with the committer’s verified signature.
dabacon Dave Bacon
@dabacon dabacon added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 12, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 12, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@CirqBot
Copy link
Collaborator

CirqBot commented Jul 12, 2022

Automerge cancelled: A required status check is not present.

Missing statuses: ['Pytest Windows (3.7)', 'Pytest Windows (3.8)', 'Pytest Windows (3.9)', 'Typescript lint check', 'Typescript tests', 'Typescript tests coverage']

@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 12, 2022
dabacon added 2 commits July 12, 2022 19:56

Verified

This commit was signed with the committer’s verified signature.
dabacon Dave Bacon

Verified

This commit was signed with the committer’s verified signature.
dabacon Dave Bacon
@dabacon dabacon added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 12, 2022
@CirqBot
Copy link
Collaborator

CirqBot commented Jul 12, 2022

Automerge cancelled: A required status check is not present.

Missing statuses: ['Coverage check', 'Pytest Windows (3.7)', 'Pytest Windows (3.8)', 'Pytest Windows (3.9)', 'Typescript lint check', 'Typescript tests', 'Typescript tests coverage']

@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 12, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@dabacon dabacon added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 12, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 12, 2022
@CirqBot CirqBot merged commit 5bfffc3 into quantumlib:master Jul 12, 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 12, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023

Verified

This commit was signed with the committer’s verified signature.
Adds missing json serialization for sweep objects.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
Adds missing json serialization for sweep objects.
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.

None yet

3 participants