-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
SummedOp: chop summands with a coefficient of 0 #5745
Comments
@Cryoris I'd like to work on this issue, if that's fine with you |
Sure, that would be great! Feel free to reach out for questions, if you have any 🙂 Once you have a draft ready you can also open a pull-request for us to look at. |
Hey @spencerking how is this going? Mind if I try? |
@VANRao-Stack I actually just got started on this yesterday. If I don't make progress this weekend I'll let you know and you can give it a shot. |
Any updates @spencerking? |
@VANRao-Stack I'm going to make a WIP PR to get some feedback. I think I've got the general idea but haven't gotten much feedback on Slack. |
Hey! I might have come up with a new method to resolve this problem. Can I open a pull request? |
@shifubear I just finished implementing it. I'm writing tests, then I'll have a PR out. |
@JosDenmark Dang, I was in the process of writing tests as well. In that case, I'll keep an eye out for your PR before I do anything else. :) |
Many thanks 🙏 |
Fixes #1096 `>>> from qiskit.aqua.operators import I, X >>> (0 * X + I) == I False # should be True` Now, we have `(0 * X + I).filter_ops_by_coeff(0, 0) == I` is true.
Fixes #1096 `>>> from qiskit.aqua.operators import I, X >>> (0 * X + I) == I False # should be True` Now, we have `(0 * X + I).filter_ops_by_coeff(0, 0) == I` or `(0 * X + I).collapse_summands() == I` is true.
I think this is closed via #7681 |
What is the expected enhancement?
A possible solution would be to add a
SummedOp.chop_summands(threshold=0)
method that is added as default call inSummedOp.reduce
, analogous tocollapse_summands
. With thethreshold
argument the user can choose what to chop: all summands with a coefficient smaller thanthreshold
are removed.This is equivalent to
WeightedPauliOperator.chop
.The text was updated successfully, but these errors were encountered: