Skip to content

Commit

Permalink
Fix VQE runtime ValueError (#182)
Browse files Browse the repository at this point in the history
* Small change.

* Update location.

* Run black.

* Update.

* Change init.

* Black.

* Update import

* Blank line.

* Update.

* Update.

* Update.

* Update path.

* Change dic

* Update pennylane_qiskit/vqe_runtime_runner.py
  • Loading branch information
rmoyard authored Feb 4, 2022
1 parent df9646a commit 127dd76
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pennylane_qiskit/vqe_runtime_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ def _callback(self, *args):
step (float): Value of the step.
accepted (bool): True if the loss function value has improved, False otherwise.
"""
_, (nfev, xk, fk, step, accepted) = args
self.intermediate_results["nfev"].append(nfev)
self.intermediate_results["parameters"].append(xk)
self.intermediate_results["function"].append(fk)
self.intermediate_results["step"].append(step)
self.intermediate_results["accepted"].append(accepted)
# If it is a dictionary it is the final result and does not belong to intermediate results
if not isinstance(args[1], dict):
_, (nfev, xk, fk, step, accepted) = args
self.intermediate_results["nfev"].append(nfev)
self.intermediate_results["parameters"].append(xk)
self.intermediate_results["function"].append(fk)
self.intermediate_results["step"].append(step)
self.intermediate_results["accepted"].append(accepted)

def _scipy_callback(self, *args):
"""The callback function that attaches intermediate results to the wrapper:
Expand Down

0 comments on commit 127dd76

Please sign in to comment.