-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Equality of SparsePauliOp
s with different orders
#7657
Comments
SparsePauliOp
s with a difference orderSparsePauliOp
s with difference orders
SparsePauliOp
s with difference ordersSparsePauliOp
s with different orders
I think this is another case of equality vs equivalence (which we discussed in an issue with @jakelishman but I can't find that discussion right now...). The conclusion, I believe, was that there's a difference between operational equality which tells us on a programmatic level if objects are the same and a functional equivalence which tells us if the objects behave the same/describe the same thing. For a = SparsePauliOp.from_list([('X', 1)])
b = SparsePauliOp.from_list([('X', 1), ('Y', 0)])
|
Imamichi-san and I discussed this issue. My opinion is this behavior is as intended but we need more documentation to |
Since we already have the |
Julien, I think the discussion we had that you're thinking about is to do with |
I tries a dict-based
If necessary, I will add |
So this will be a breaking change in regards of how we had things before? E..g this here that although its in the SummedOp docs, this nowdays produces a PauliSumOp underneath, using a SparsePauliOp, but it works just the same |
I made #7656 so that it won't break changes The summary is
|
What is the expected enhancement?
Two
SparsePauliOp
s with different orders are judges as "not equal" as follows.output
Is it better to return
True
for this comparison or mention the order dependency in the docsting of__eq__
?@ikkoham also told me another case as follow. A redundant operator (coeff is 0) makes the comparison "not equal".
If we need to compare two operator with different order and/or redundant operators, I think we need to call as follows. Is there any simple alternatives?
Update
I updated
SparsePauliOp
in #7656 as follows.__eq__
as is (elementary-wise comparison)equiv
for equivalence checkThe text was updated successfully, but these errors were encountered: