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

Make InsertionNoiseModel serializable #6249

Closed
epelaaez opened this issue Aug 16, 2023 · 6 comments · Fixed by #6282
Closed

Make InsertionNoiseModel serializable #6249

epelaaez opened this issue Aug 16, 2023 · 6 comments · Fixed by #6282
Assignees
Labels
area/serialization good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/feature-request Describes new functionality triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add

Comments

@epelaaez
Copy link
Contributor

Is your feature request related to a use case or problem? Please describe.
Currently, InsertionNoiseModel is not serializable, while NoiseModel is. It would be useful if InsertionNoiseModel was serializable as well.

Calling cirq.to_json(noise_model) where noise_model is a InsertionNoiseModel currently raises the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

[...]

File /usr/lib/python3.10/json/encoder.py:179, in JSONEncoder.default(self, o)
    160 def default(self, o):
    161     """Implement this method in a subclass such that it returns
    162     a serializable object for ``o``, or calls the base implementation
    163     (to raise a ``TypeError``).
   (...)
    177 
    178     """
--> 179     raise TypeError(f'Object of type {o.__class__.__name__} '
    180                     f'is not JSON serializable')

 

TypeError: Object of type InsertionNoiseModel is not JSON serializable

Describe the solution you'd like
Being able to call cirq.to_json(noise_model) where noise_model is a InsertionNoiseModel.

What is the urgency from your perspective for this issue? Is it blocking important work?

P1 - Not urgent but would be nice to be able to serialize these noise models

@epelaaez epelaaez added the kind/feature-request Describes new functionality label Aug 16, 2023
@tanujkhattar tanujkhattar added the good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. label Aug 16, 2023
@tanujkhattar tanujkhattar added triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add area/serialization labels Aug 16, 2023
@suyashdamle
Copy link
Contributor

I'd like to take this one up as my first issue

@tanujkhattar
Copy link
Collaborator

InsertionNoiseModel is already a dataclass so it should be fairly straightforward to fix this.

@vtomole
Copy link
Collaborator

vtomole commented Aug 21, 2023

@suyashdamle Go ahead. I've assigned you.

@vtomole
Copy link
Collaborator

vtomole commented Sep 6, 2023

Hey @suyashdamle, are you working on this? If not, @epelaaez do you want to take this?

@suyashdamle
Copy link
Contributor

Yes - I'm working on it.

@vtomole
Copy link
Collaborator

vtomole commented Sep 6, 2023

Awesome 👌. Thanks 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/serialization good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/feature-request Describes new functionality triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants