Skip to content

[BUG] qml.TShift power method is incorrect #6355

Open
@willjmax

Description

Expected behavior

Raising a TShift operator to the power of 2 should return something.

Actual behavior

The current implementation of pow on the TShift operator is given by

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

which calls the pow method on the Operator class, given by

        if z == 0:
            return []
        if z == 1:
            if QueuingManager.recording():
                return [qml.apply(self)]
            return [copy.copy(self)]
        raise PowUndefinedError

So, attempting to raise a TShift to the power of 2 results in a PowUndefinedError.

Additional information

No response

Source code

No response

Tracebacks

No response

System information

Name: PennyLane
Version: 0.39.0.dev25
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: https://github.com/PennyLaneAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /home/william.maxwell/venvs/pl-py3.10/lib/python3.10/site-packages
Editable project location: /home/william.maxwell/pennylane/pennylane
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, toml, typing-extensions
Required-by: amazon-braket-pennylane-plugin, PennyLane-Catalyst, PennyLane_Lightning, PennyLane_Lightning_Kokkos

Platform info:           Linux-6.8.0-45-generic-x86_64-with-glibc2.35
Python version:          3.10.12
Numpy version:           1.26.4
Scipy version:           1.12.0
Installed devices:
- lightning.qubit (PennyLane_Lightning-0.39.0.dev24)
- default.clifford (PennyLane-0.39.0.dev25)
- default.gaussian (PennyLane-0.39.0.dev25)
- default.mixed (PennyLane-0.39.0.dev25)
- default.qubit (PennyLane-0.39.0.dev25)
- default.qutrit (PennyLane-0.39.0.dev25)
- default.qutrit.mixed (PennyLane-0.39.0.dev25)
- default.tensor (PennyLane-0.39.0.dev25)
- null.qubit (PennyLane-0.39.0.dev25)
- reference.qubit (PennyLane-0.39.0.dev25)
- lightning.kokkos (PennyLane_Lightning_Kokkos-0.39.0.dev24)
- nvidia.custatevec (PennyLane-Catalyst-0.9.0.dev12)
- nvidia.cutensornet (PennyLane-Catalyst-0.9.0.dev12)
- oqc.cloud (PennyLane-Catalyst-0.9.0.dev12)
- softwareq.qpp (PennyLane-Catalyst-0.9.0.dev12)
- braket.aws.ahs (amazon-braket-pennylane-plugin-1.30.1)
- braket.aws.qubit (amazon-braket-pennylane-plugin-1.30.1)
- braket.local.ahs (amazon-braket-pennylane-plugin-1.30.1)
- braket.local.qubit (amazon-braket-pennylane-plugin-1.30.1)

Existing GitHub issues

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions