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

Fix result print for SamplingVQE & QAOA - fixes #58 #65

Merged
merged 4 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions qiskit_algorithms/minimum_eigensolvers/sampling_mes.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,3 @@ def best_measurement(self) -> Mapping[str, Any] | None:
def best_measurement(self, value: Mapping[str, Any]) -> None:
"""Set the best measurement over the entire optimization."""
self._best_measurement = value

def __str__(self) -> str:
"""Return a string representation of the result."""
disp = (
"SamplingMinimumEigensolverResult:\n"
+ f"\tEigenvalue: {self.eigenvalue}\n"
+ f"\tBest measurement\n: {self.best_measurement}\n"
)
if self.aux_operators_evaluated is not None:
disp += f"\n\tAuxiliary operator values: {self.aux_operators_evaluated}\n"

return disp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
other:
- |
Removed the custom ``__str__`` method from :class:`.SamplingMinimumEigensolverResult`
so that string conversion is based on the method of its parent :class:`.AlgorithmResult`
which prints all the result fields in a dictionary like format. The overridden method
had only printed a select couple of fields, unlike when normally printing a result all fields
are shown, and the lack of fields expected to be shown caused confusion when printing
results derived from that, such as returned by :class:`.SamplingVQE` and :class:`.QAOA`.