-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add json serialization to sweeps #5618
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fb94d3c
Add json serialization to sweeps
dabacon 92de909
Merge branch 'master' into morejson
dabacon ae3a915
Merge branch 'master' into morejson
dabacon 46ffe6d
Merge branch 'master' into morejson
dabacon 9bad794
Merge branch 'master' into morejson
dabacon 3c67175
Merge branch 'master' into morejson
dabacon 5fa5196
Merge branch 'master' into morejson
dabacon 30c8173
Merge branch 'master' into morejson
dabacon 9453f16
fix tests
dabacon 245eee4
Merge branch 'morejson' of github.com:dabacon/Cirq into morejson
dabacon e13d628
Merge branch 'master' into morejson
CirqBot 20eb907
Merge branch 'master' into morejson
dabacon 37369fb
Merge branch 'morejson' of github.com:dabacon/Cirq into morejson
dabacon ab78042
Merge branch 'master' into morejson
dabacon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "cirq_type": "Linspace", | ||
| "key": "a", | ||
| "start": 0, | ||
| "stop": 1, | ||
| "length": 4 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| cirq.Linspace("a", start=0, stop=1, length=4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "cirq_type": "ListSweep", | ||
| "resolver_list": [ | ||
| { | ||
| "cirq_type": "ParamResolver", | ||
| "param_dict": [ | ||
| [ | ||
| "a", | ||
| 0.1 | ||
| ] | ||
| ] | ||
| }, | ||
| { | ||
| "cirq_type": "ParamResolver", | ||
| "param_dict": [ | ||
| [ | ||
| "b", | ||
| 0.2 | ||
| ] | ||
| ] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| cirq.ListSweep([cirq.ParamResolver({'a': 0.1}), cirq.ParamResolver({'b': 0.2})]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "cirq_type": "Points", | ||
| "key": "a", | ||
| "points": [ | ||
| 0, | ||
| 0.4 | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| cirq.Points('a', [0, 0.4]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "cirq_type": "Product", | ||
| "factors": [ | ||
| { | ||
| "cirq_type": "Linspace", | ||
| "key": "a", | ||
| "start": 0, | ||
| "stop": 1, | ||
| "length": 2 | ||
| }, | ||
| { | ||
| "cirq_type": "Linspace", | ||
| "key": "b", | ||
| "start": 0, | ||
| "stop": 2, | ||
| "length": 4 | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| cirq.Product(cirq.Linspace('a', start=0, stop=1, length=2), cirq.Linspace('b', start=0, stop=2, length=4)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "cirq_type": "Zip", | ||
| "sweeps": [ | ||
| { | ||
| "cirq_type": "Linspace", | ||
| "key": "a", | ||
| "start": 0, | ||
| "stop": 1, | ||
| "length": 2 | ||
| }, | ||
| { | ||
| "cirq_type": "Linspace", | ||
| "key": "b", | ||
| "start": 0, | ||
| "stop": 2, | ||
| "length": 4 | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| cirq.Zip(cirq.Linspace('a', start=0, stop=1, length=2), cirq.Linspace('b', start=0, stop=2, length=4)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "cirq_type": "_Unit" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| cirq.UnitSweep |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Based on the name,
_Unitis a private class. Do we want it to be serializable?If so, I think this needs a
_from_json_dict_classmethod.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.
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 deserializecirq.UnitSweepcorrectly (should beUNIT_SWEEPbtw), which it does. I think you can also use it to serialize and deserialize_Unitby going in and grabbing that class explicitly, but I don't know a way to stop this for this singleton pattern.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.
SGTM. This can merge once the tests are sorted out.