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

Implement more complete JSON serialization for sympy #2014

Closed
mpharrigan opened this issue Aug 22, 2019 · 2 comments
Closed

Implement more complete JSON serialization for sympy #2014

mpharrigan opened this issue Aug 22, 2019 · 2 comments

Comments

@mpharrigan
Copy link
Collaborator

Follow up to #1880 (review)

It would be ideal if sympy itself had a serialization format. However, the most promising candidate srepr looks to be horribly unsafe to parse on untrusted input.

#1880 adds support for sympy.Symbol, but we'll probably need support for more constructs; at least arithmetic

Strilanc added a commit that referenced this issue Oct 10, 2019
- Add support for the types needed to make linear combinations in sympy
- Use a stricter pandas equality check in the tests
- Handle pd.Index and pd.MultiIndex recursively
- Fix index type not being preserved and multi-index just not working
- Fix column index name being lost
- Separate testing of external/builtin json round tripping from testing of cirq stuff

Part of #2014
CirqBot pushed a commit that referenced this issue Oct 10, 2019
- Add support for the types needed to make linear combinations in sympy
- Use a stricter pandas equality check in the tests
- Handle pd.Index and pd.MultiIndex recursively
- Fix index type not being preserved and multi-index just not working
- Fix column index name being lost
- Separate testing of external/builtin json round tripping from testing of cirq stuff

Part of #2014
@dabacon
Copy link
Collaborator

dabacon commented May 5, 2020

More support has been added for simple math. Do we have more we'd like to add? I'd recommend we close until we see if there is more complicated math that starts showing up that we need to serialize.

@mpharrigan
Copy link
Collaborator Author

Sounds good to me!

CirqBot pushed a commit that referenced this issue Jun 13, 2022
#2014 has been fixed and the following code snippet now works as expected.  

```python
>>> import cirq, sympy
>>> circuit = cirq.Circuit(cirq.rx(sympy.Symbol('theta')).on(cirq.NamedQubit("q")))
>>> cirq.testing.assert_json_roundtrip_works(circuit) # works.
```
rht pushed a commit to rht/Cirq that referenced this issue May 1, 2023
quantumlib#2014 has been fixed and the following code snippet now works as expected.  

```python
>>> import cirq, sympy
>>> circuit = cirq.Circuit(cirq.rx(sympy.Symbol('theta')).on(cirq.NamedQubit("q")))
>>> cirq.testing.assert_json_roundtrip_works(circuit) # works.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants