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 handling of numpy arrays for indices in marginal_distribution #8288

Merged
merged 3 commits into from
Jul 25, 2022

Conversation

mtreinish
Copy link
Member

Summary

This commit fixes an issue with the marginal_distribution() function
where it would previously error if a numpy arrray of ints was passed in
for the indices parameter. This was caused by the input validation
looking for empty input by checking not indices which isn't valid for
numpy arrays. This commit fixes this by adjusting the check for
empty lists to work with any sequence input.

Details and comments

Fixes #8283

This commit fixes an issue with the marginal_distribution() function
where it would previously error if a numpy arrray of ints was passed in
for the indices parameter. This was caused by the input validation
looking for empty input by checking `not indices` which isn't valid for
numpy arrays. This commit fixes this by adjusting the check for
empty lists to work with any sequence input.

Fixes Qiskit#8283
@mtreinish mtreinish added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog labels Jul 1, 2022
@mtreinish mtreinish requested a review from a team as a code owner July 1, 2022 19:31
@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:

  • @Qiskit/terra-core

@mtreinish mtreinish added this to the 0.21.1 milestone Jul 1, 2022
@coveralls
Copy link

Pull Request Test Coverage Report for Build 2598717170

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.005%) to 83.965%

Totals Coverage Status
Change from base Build 2596909208: 0.005%
Covered Lines: 55778
Relevant Lines: 66430

💛 - Coveralls

Copy link
Contributor

@Cryoris Cryoris left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏻

@mergify mergify bot merged commit f868129 into Qiskit:main Jul 25, 2022
mergify bot pushed a commit that referenced this pull request Jul 25, 2022
)

* Fix handling of numpy arrays for indices in marginal_distribution

This commit fixes an issue with the marginal_distribution() function
where it would previously error if a numpy arrray of ints was passed in
for the indices parameter. This was caused by the input validation
looking for empty input by checking `not indices` which isn't valid for
numpy arrays. This commit fixes this by adjusting the check for
empty lists to work with any sequence input.

Fixes #8283

* Update releasenotes/notes/fix-numpy-indices-marginal-dist-45889e49ba337d84.yaml

Co-authored-by: Jim Garrison <jim@garrison.cc>

Co-authored-by: Jim Garrison <jim@garrison.cc>
(cherry picked from commit f868129)
mergify bot added a commit that referenced this pull request Jul 25, 2022
) (#8396)

* Fix handling of numpy arrays for indices in marginal_distribution

This commit fixes an issue with the marginal_distribution() function
where it would previously error if a numpy arrray of ints was passed in
for the indices parameter. This was caused by the input validation
looking for empty input by checking `not indices` which isn't valid for
numpy arrays. This commit fixes this by adjusting the check for
empty lists to work with any sequence input.

Fixes #8283

* Update releasenotes/notes/fix-numpy-indices-marginal-dist-45889e49ba337d84.yaml

Co-authored-by: Jim Garrison <jim@garrison.cc>

Co-authored-by: Jim Garrison <jim@garrison.cc>
(cherry picked from commit f868129)

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
@mtreinish mtreinish deleted the fix-paul-numpy-indices branch July 25, 2022 17:47
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 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.

marginal_distribution raises for NumPy array indices
5 participants