Skip to content

Commit

Permalink
add warning about applying a queued operator (#4311)
Browse files Browse the repository at this point in the history
* add warning about applying a queued operator

* move warning into warning block
  • Loading branch information
timmysilv committed Jul 4, 2023
1 parent 78f1199 commit 454134e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pennylane/queuing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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─┤ <Z>
.. details::
:title: Usage Details
Expand Down

0 comments on commit 454134e

Please sign in to comment.