Skip to content

Commit

Permalink
Fix result print for SamplingVQE & QAOA - fixes #58 (#65)
Browse files Browse the repository at this point in the history
Co-authored-by: Elena Peña Tapia <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 23, 2023
1 parent 820eaff commit f433cf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
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`.

0 comments on commit f433cf0

Please sign in to comment.