-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Bug fix on QNSPSA #9483
Bug fix on QNSPSA #9483
Conversation
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
Hi @luciacuervovalor, could you add a small test and a bugfix release note? 🙂 |
@@ -228,9 +228,10 @@ def _point_sample(self, loss, x, eps, delta1, delta2): | |||
gradient_estimate = (loss_values[0] - loss_values[1]) / (2 * eps) * delta1 | |||
|
|||
# compute the preconditioner point estimate | |||
fidelity_values = [float(f) for f in fidelity_values] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the casts to float still required now that we explicitly use diff = diff / thing
instead of diff /= thing
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so because it failed again with diff = diff / thing
with the same error
Co-authored-by: Julien Gacon <gaconju@gmail.com>
…erra into qnspsa_fix_bug
def test_point_sample(self): | ||
"""Test point sample function in QNSPSA""" | ||
|
||
def fidelity(x, y): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pylint's moaning about the unused y
argument. Given this is just a stub function, you can make it shut up by giving the second argument a name starting with an underscore, like _y
- that means "explicitly ignored".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh man, and now Pylint's complaining that that's not a valid name... I'm not a fan of these pylint rules at all.
At any rate, you can put a comment just under the docstring of test_point_sample
that says # pylint: disable=invalid-name
or # pylint: disable=unused-argument
as appropriate (depending on which name for the argument you prefer using).
Pull Request Test Coverage Report for Build 4072796493
💛 - Coveralls |
The name of variable "_y" must have this form because the argument is unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change LGTM! Thanks @luciacuervovalor :)
* Bug fix Old syntax was giving type error when dividing int by float * Bug fix * Convert to float to avoid type error * Add unit test * Add release note * Update releasenotes/notes/qnspsa-float-bug-fix-4035f7e1eb61dec2.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Ran black * Make unused argument explicitly ignored * Change to np array syntax * Pylint disable invalid name The name of variable "_y" must have this form because the argument is unused * Make black --------- Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: ElePT <epenatap@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 2f49b5a)
* Bug fix Old syntax was giving type error when dividing int by float * Bug fix * Convert to float to avoid type error * Add unit test * Add release note * Update releasenotes/notes/qnspsa-float-bug-fix-4035f7e1eb61dec2.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Ran black * Make unused argument explicitly ignored * Change to np array syntax * Pylint disable invalid name The name of variable "_y" must have this form because the argument is unused * Make black --------- Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: ElePT <epenatap@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 2f49b5a) Co-authored-by: luciacuervovalor <67261900+luciacuervovalor@users.noreply.github.com> Co-authored-by: Jake Lishman <jake.lishman@ibm.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Bug fix Old syntax was giving type error when dividing int by float * Bug fix * Convert to float to avoid type error * Add unit test * Add release note * Update releasenotes/notes/qnspsa-float-bug-fix-4035f7e1eb61dec2.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Ran black * Make unused argument explicitly ignored * Change to np array syntax * Pylint disable invalid name The name of variable "_y" must have this form because the argument is unused * Make black --------- Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: ElePT <epenatap@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Bug fix Old syntax was giving type error when dividing int by float * Bug fix * Convert to float to avoid type error * Add unit test * Add release note * Update releasenotes/notes/qnspsa-float-bug-fix-4035f7e1eb61dec2.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Ran black * Make unused argument explicitly ignored * Change to np array syntax * Pylint disable invalid name The name of variable "_y" must have this form because the argument is unused * Make black --------- Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: ElePT <epenatap@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Bug fix Old syntax was giving type error when dividing int by float * Bug fix * Convert to float to avoid type error * Add unit test * Add release note * Update releasenotes/notes/qnspsa-float-bug-fix-4035f7e1eb61dec2.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Ran black * Make unused argument explicitly ignored * Change to np array syntax * Pylint disable invalid name The name of variable "_y" must have this form because the argument is unused * Make black --------- Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: ElePT <epenatap@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Old syntax was giving type error when dividing int by float
Summary
Minor syntax change because the old one gave random type errors .
Details and comments
Very minor change, no important details