From 454134e21295fb9da4e74980360d89c287ef02dc Mon Sep 17 00:00:00 2001 From: Matthew Silverman Date: Tue, 4 Jul 2023 14:49:23 -0400 Subject: [PATCH] add warning about applying a queued operator (#4311) * add warning about applying a queued operator * move warning into warning block --- pennylane/queuing.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pennylane/queuing.py b/pennylane/queuing.py index 1b99b5f8328..e2c84602e0e 100644 --- a/pennylane/queuing.py +++ b/pennylane/queuing.py @@ -459,6 +459,22 @@ def circuit(x): >>> print(qml.draw(circuit)(0.6)) 0: ──RX(0.4)──RY(0.6)──RX(0.4)──┤ ⟨Z⟩ + .. warning:: + + If you use ``apply`` on an operator that has already been queued, it will + be queued for a second time. For example: + + .. code-block:: python + + @qml.qnode(dev) + def circuit(): + op = qml.Hadamard(0) + qml.apply(op) + return qml.expval(qml.PauliZ(0)) + + >>> print(qml.draw(circuit)()) + 0: ──H──H─┤ + .. details:: :title: Usage Details