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

[from qiskit] Use dataclass for AlgorithmResult #53

Open
ElePT opened this issue Aug 22, 2023 · 2 comments
Open

[from qiskit] Use dataclass for AlgorithmResult #53

ElePT opened this issue Aug 22, 2023 · 2 comments

Comments

@ElePT
Copy link
Collaborator

ElePT commented Aug 22, 2023

What should we add?

Now that the Python 3.6 support is dropped we can use dataclasses in Qiskit. Since our AlgorithmResult was essentially a dictionary replacement we implemented ourselves, should we switch to simply using dataclass as an algorithm result?

That would have advantages like

  • much less overhead in writing algorithm results since no getters/setters are required (the docs can go into the class docstring)
  • access to dataclass features such as easy conversion to dicts or easily creating immutable results
@ElePT
Copy link
Collaborator Author

ElePT commented Aug 22, 2023

Opened by @Cryoris
Original issue & discussion: Qiskit/qiskit#8437

@woodsp-ibm
Copy link
Member

Also we should see whether we want/need to have something custom for a printable output - see comments in #58. The dataclass has a repr but potentially that may be viewed to have similar problems to the default in AlgorithmResult. Of course an end user can print any field they like - this was always a convenience to see everything - but everything may not scale well and a short result firm e.g. just the eigenvalue when thats what you are computing for, I can see too.

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