-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement JSON serialization for PauliSum #3071
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
Comments
@mpharrigan this is going to require serializing frozenset. Do you have any objections to this? I'm going to do it in a way that it preserves roundtrip (there is a crazy cool hack you could do which is to pass in the values of the set as keys in a dict with all values None, but figure that's not a good practice :) ) |
Do you mean adding generic support for frozensets in the cirq encoder? Or custom logic in If the latter, that's expected although the plumbing is a little intricate in this particular case. If the former, how do you intend to tag the resulting JSON so it's known to be a frozenset during deserialization? |
Oh I was thinking the former, but you are correct that could be a way to handle it. Was just going to re-use the "cirq_type" with frozenset. An alternative would be to create a different key "builtin-type". I think there was some discussion of this problem over in the numpy array serialization discussion. Now that I think about it maybe your first suggestion is the better approach. |
Let me know how it goes. I'm not opposed to adding support for more basic containers in principle. I think since |
I wanted to see what it looked like. One issue you run into is tuples, which are default serialized to lists. You can fix this https://stackoverflow.com/questions/15721363/preserve-python-tuples-with-json but not really a great hack. |
Fixes #3071 One approach to this would have been to serialize frozenset and tuple in Cirq, but this instead takes the approach of not relying on this but appropriately serializing and deserializing these.
Fixes quantumlib#3071 One approach to this would have been to serialize frozenset and tuple in Cirq, but this instead takes the approach of not relying on this but appropriately serializing and deserializing these.
Fixes quantumlib#3071 One approach to this would have been to serialize frozenset and tuple in Cirq, but this instead takes the approach of not relying on this but appropriately serializing and deserializing these.
No description provided.
The text was updated successfully, but these errors were encountered: