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

Implement iterating/collecting PauliSumOp coefficients #5547 #5560

Merged
merged 7 commits into from
Jan 12, 2021

Conversation

paolob67
Copy link
Contributor

Summary

Fixes #5547

  • Added the coeffs property to return the operator coefficients as a numpy array
  • Added a matrix iterator by leveraging the same code used in the PauliSparseOperator
  • Added tests for the iterator

Details and comments

This fix provides the ability of being able to iterate over, or return a list of coefficients in PauliSumOp. At present, one has to dig into the details to construct the coefficients for each term. In particular, it requires multiplying two numbers for each coeffcient. There are use cases, for instance when bounding the eigenvalues of the operators.
The coeffs property returns a numpy array of the operator obtained by multiplying the coeffs of the primitive by the coefficient provided in the constructor.
The matrix iterator iterates through the Pauli table representing the the PauliSumOp in either sparse or not fashion.

@CLAassistant
Copy link

CLAassistant commented Dec 25, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@ikkoham ikkoham left a comment

Choose a reason for hiding this comment

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

Very nice. Just a small comment.

test/python/opflow/test_pauli_sum_op.py Outdated Show resolved Hide resolved
@paolob67
Copy link
Contributor Author

paolob67 commented Jan 4, 2021

The Qiskit.qiskit-terra (Python_Tests Tutorials Python38) pipeline is failing after the commit on the PR but I really don't know how to fix that. Any help is appreciated. Thanks.

@jlapeyre
Copy link
Contributor

jlapeyre commented Jan 4, 2021

pipeline is failing after the commit on the PR

It may be unrelated to this PR. There is probably a way to re-run it.

@kdk
Copy link
Member

kdk commented Jan 4, 2021

pipeline is failing after the commit on the PR

It may be unrelated to this PR. There is probably a way to re-run it.

I triggered a re-run and it passed. Maybe a transient azure issue?

@mergify mergify bot merged commit bfb4262 into Qiskit:master Jan 12, 2021
@paolob67 paolob67 deleted the issue#5547 branch January 12, 2021 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement iterating/collecting PauliSumOp coefficients
7 participants