SingleQubitCliffordGate does not properly serialize to JSON
See original GitHub issueDescription of the issue
SingleQubitCliffordGate
s write incomplete information to JSON, and their type cannot be understood by the JSON deserializer.
How to reproduce the issue
>>> import cirq
>>> print(cirq.__version__)
0.10.0
>>> q = cirq.LineQubit(0)
>>> json_text = cirq.to_json(cirq.SingleQubitCliffordGate.X(q))
>>> print(json_text)
{
"cirq_type": "GateOperation",
"gate": {
"cirq_type": "SingleQubitCliffordGate"
},
"qubits": [
{
"cirq_type": "LineQubit",
"x": 0
}
]
}
>>> deserialized_gate = cirq.read_json(json_text=json_text)
ValueError: Could not resolve type 'SingleQubitCliffordGate' during deserialization
Cirq version
0.10.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Unable to Serialize JSON to Dictionary - Stack Overflow
I think your JSON which you are attempting to de-serialize is not conforming to your class definition. Try changing the way you are ......
Read more >System.Text.Json source generator fallback - .NET
Json source generator will no longer implicitly fall back to reflection-based serialization for unrecognized types. Previous behavior. Consider ...
Read more >Serialization Guide - Json.NET
The Json.NET serializer can serialize a wide variety of .NET objects. This guide looks at ... Array (properties on the collection will not...
Read more >How to Serialize a Class Object to JSON in Python
TypeError : Object of type ImageLabel is not JSON serializable ... Outputs a proper JSON: Serialization results are proper JSON objects. print() just...
Read more >JSON Serialization Usage
So it doesn't matter how deep your object path has gotten. An exclude of *.class will match to any path depth. So if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, please take it. I will be able to contribute to Cirq from the month of September.
Hi @PoPaT1618 - thank you for volunteering!
I saw that you are new to the project, so, just to clarify, the following needs to be done:
SingleQubitCliffordGate
from this list: https://github.com/quantumlib/Cirq/blob/a41df7f97a9eddba8fcaa4c19c6366acd67de4de/cirq-core/cirq/protocols/json_test_data/spec.py#L67cirq-core/cirq/protocols/json_serialization_test.py
pass (you can run it withcheck/pytest cirq-core/cirq/protocols/json_serialization_test.py
)_json_dict_
magic method for the json serialization protocol within theSingleQubitCliffordGate
class, along the lines of:At this point you might be ready to commit, and create a pull request, but ping us if you run into issues.
Thanks!