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

Add back repr for Result and related classes #4987

Merged
merged 12 commits into from
Oct 5, 2020

Conversation

mtreinish
Copy link
Member

Summary

In the removal of marshmallow from the Result class (and terra as a
whole) in #4030 the descriptive repr for the objects was lost. This is
inconvenient because the default representation for an object is just
the class name and the memory address of the object. This commit adds
back a string representation of the objects which were missing by adding
a repr method to the classes.

Details and comments

In the removal of marshmallow from the Result class (and terra as a
whole) in Qiskit#4030 the descriptive repr for the objects was lost. This is
inconvenient because the default representation for an object is just
the class name and the memory address of the object. This commit adds
back a string representation of the objects which were missing by adding
a __repr__ method to the classes.
@mtreinish mtreinish requested a review from a team as a code owner August 26, 2020 20:43
@mtreinish
Copy link
Member Author

If people are curious an example output from repr(Result) is:

Result(backend_name='2.0.0', backend_version='2.0.0', qobj_id='d0d7793e-743a-4af1-ab6a-c635c42e3c95', job_id='2e80dbb7-e368-47fa-b96e-217363823d2f', success=True, results=[ExperimentResult(shots=1024, success=True, meas_level=MeasLevel.CLASSIFIED, data=ExperimentResultData(counts={'0x0': 525, '0x3': 499}), header=QobjExperimentHeader(clbit_labels=[['c', 0], ['c', 1]], creg_sizes=[['c', 2]], global_phase=0, memory_slots=2, n_qubits=2, name='circuit0', qreg_sizes=[['q', 2]], qubit_labels=[['q', 0], ['q', 1]]), status=DONE, name='circuit0', seed_simulator=670299412, time_taken=0.0029897689819335938)], status=COMPLETED, status=QobjHeader(), time_taken=0.0030059814453125)

@kdk kdk added this to the 0.16 milestone Sep 15, 2020
Copy link
Member

@1ucian0 1ucian0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to add a test for this?

@mtreinish
Copy link
Member Author

I can, but it's not like it's a critical piece it's just a string representation of the data in there.

@mtreinish mtreinish requested a review from 1ucian0 October 3, 2020 18:19
@mergify mergify bot merged commit b435c9b into Qiskit:master Oct 5, 2020
@mtreinish mtreinish deleted the add-result-repr branch October 5, 2020 14:55
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

Successfully merging this pull request may close these issues.

4 participants