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] qml.equal does not understand nesting in sums #5162

Closed
1 task done
Qottmann opened this issue Feb 6, 2024 · 0 comments
Closed
1 task done

[BUG] qml.equal does not understand nesting in sums #5162

Qottmann opened this issue Feb 6, 2024 · 0 comments
Labels
bug 🐛 Something isn't working

Comments

@Qottmann
Copy link
Contributor

Qottmann commented Feb 6, 2024

Expected behavior

X, Y, Z, I = qml.PauliX, qml.PauliY, qml.PauliZ, qml.Identity
qml.operation.enable_new_opmath()
op1 = (
    0.5 * X(0)
  + 0.5 * X(1)
  + 0.5 * X(2)
  + 0.5 * X(3)
  + 0.5 * X(4)
  + 0.5 * X(5)
  + 0.5 * X(6)
  + 0.5 * X(7)
  + 0.5 * X(8)
  + 0.5 * X(9)
)
op2 = qml.sum(*[0.5 * X(i) for i in range(10)])
>>> qml.equal(op1, op2)
True

Actual behavior

op1 = (
    0.5 * X(0)
  + 0.5 * X(1)
  + 0.5 * X(2)
  + 0.5 * X(3)
  + 0.5 * X(4)
  + 0.5 * X(5)
  + 0.5 * X(6)
  + 0.5 * X(7)
  + 0.5 * X(8)
  + 0.5 * X(9)
)
op2 = qml.sum(*[0.5 * X(i) for i in range(10)])
>>> qml.equal(op1, op2)
False

Additional information

qml.equal seems to not understand nesting in Sum.

Source code

No response

Tracebacks

No response

System information

latest main branch

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.

[sc-56466]

@Qottmann Qottmann added the bug 🐛 Something isn't working label Feb 6, 2024
albi3ro pushed a commit that referenced this issue Feb 9, 2024
**Potential** fix for
#5162 and many other
related issues
Simply compares the pauli_rep between operators, when both have one.

[sc-56466]

---------

Co-authored-by: Mudit Pandey <[email protected]>
@Qottmann Qottmann closed this as completed Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant