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

Bug fix on QNSPSA #9483

Merged
merged 13 commits into from
Feb 2, 2023
Merged

Bug fix on QNSPSA #9483

merged 13 commits into from
Feb 2, 2023

Conversation

luciacuervovalor
Copy link
Contributor

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

Old syntax was giving type error when dividing int by float
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jan 30, 2023
@CLAassistant
Copy link

CLAassistant commented Jan 30, 2023

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@qiskit-bot
Copy link
Collaborator

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:

@Cryoris
Copy link
Contributor

Cryoris commented Jan 30, 2023

Hi @luciacuervovalor, could you add a small test and a bugfix release note? 🙂

@ElePT ElePT added bug Something isn't working Intern PR PR submitted by IBM Quantum interns Changelog: Bugfix Include in the "Fixed" section of the changelog mod: algorithms Related to the Algorithms module and removed Community PR PRs from contributors that are not 'members' of the Qiskit repo bug Something isn't working labels Jan 30, 2023
@@ -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]
Copy link
Contributor

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?

Copy link
Contributor Author

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

def test_point_sample(self):
"""Test point sample function in QNSPSA"""

def fidelity(x, y):
Copy link
Member

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".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks!

Copy link
Member

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).

@Cryoris Cryoris added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Feb 1, 2023
@coveralls
Copy link

coveralls commented Feb 1, 2023

Pull Request Test Coverage Report for Build 4072796493

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 111 unchanged lines in 8 files lost coverage.
  • Overall coverage decreased (-0.02%) to 85.245%

Files with Coverage Reduction New Missed Lines %
qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py 2 97.01%
qiskit/transpiler/passmanager.py 2 93.65%
qiskit/pulse/library/waveform.py 3 91.67%
qiskit/algorithms/state_fidelities/compute_uncompute.py 4 93.75%
qiskit/circuit/register.py 6 93.94%
qiskit/pulse/calibration_entries.py 13 87.88%
qiskit/transpiler/passes/calibration/rzx_builder.py 22 87.06%
qiskit/visualization/pass_manager_visualization.py 59 17.53%
Totals Coverage Status
Change from base Build 4028718413: -0.02%
Covered Lines: 67109
Relevant Lines: 78725

💛 - Coveralls

The name of variable "_y" must have this form because the argument is unused
@jakelishman jakelishman added this to the 0.23.2 milestone Feb 1, 2023
Copy link
Contributor

@ElePT ElePT left a 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 :)

@ElePT ElePT added the automerge label Feb 2, 2023
@mergify mergify bot merged commit 2f49b5a into Qiskit:main Feb 2, 2023
mergify bot pushed a commit that referenced this pull request Feb 2, 2023
* 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)
mergify bot added a commit that referenced this pull request Feb 3, 2023
* 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>
pranay1990 pushed a commit to pranay1990/qiskit-terra that referenced this pull request Feb 9, 2023
* 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>
ElePT added a commit to ElePT/qiskit that referenced this pull request Jun 27, 2023
* 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>
ElePT added a commit to ElePT/qiskit-algorithms-test that referenced this pull request Jul 17, 2023
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog Intern PR PR submitted by IBM Quantum interns mod: algorithms Related to the Algorithms module stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants