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

[WIP][Bug Fix] Fixing the pow method on qml.TShift #6356

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

willjmax
Copy link
Contributor

@willjmax willjmax commented Oct 7, 2024

This PR fixes issue #6355 by providing proper pow implementations for qml.TShift, qml.TAdd, and qml.TClock. Each of these operators implement pow in the following way.

def pow(self, z):
    return super().pow(z % 3)

This is calling the pow method on Operator which handles the cases for z==0 and z==1 but returns a PowUndefinedError for any other value of z. This leads to an error for TShift, TAdd, and TClock when raising to the second power. This PR implements the case when z is a non-negative integer by returning a list containing z copies of the operator.

Copy link
Contributor

github-actions bot commented Oct 7, 2024

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

pennylane/operation.py Outdated Show resolved Hide resolved
pennylane/operation.py Outdated Show resolved Hide resolved
@willjmax willjmax changed the title [Bug Fix] Fixing the pow method on qml.TShift [WIP][Bug Fix] Fixing the pow method on qml.TShift Oct 8, 2024
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.

2 participants