PennyLaneAI / pennylane

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.
https://pennylane.ai
Apache License 2.0
2.27k stars 586 forks source link

Raise an error when instantiating an operator with `wires=[]` #2829

Closed AlbertMitjans closed 2 years ago

AlbertMitjans commented 2 years ago

Feature details

Operators that have num_wires = AnyWires or num_wires = AllWires (such as qml.Barrier) are applied to all wires when instantiated with wires = []. This is the default behaviour for the qml.Barrier operation, but generally we want to raise an error when this happens.

This feature request follows the issue https://github.com/PennyLaneAI/pennylane/issues/2496, which was solved by the PR https://github.com/PennyLaneAI/pennylane/pull/2826.

Implementation

See PR https://github.com/PennyLaneAI/pennylane/pull/2511.

How important would you say this feature is?

1: Not important. Would be nice to have.

Additional information

No response

meenu-kri commented 2 years ago

Hi @antalszava and @AlbertMitjans, I have created the PR for this issue and it is ready to review.