qml.drawer.label¶
- label(op, new_label)[source]¶
Labels an operator with a custom label.
Warning
This function is not currently supported inside
qjit()-compiled circuits.- Parameters:
op (Operator) – The operator you wish to mark.
new_label (str) – The label you wish to give to the operator.
Example:
>>> op = qml.X(0) >>> labelled_op = qml.drawer.label(op, "my-x") >>> print(labelled_op.custom_label) my-x
The custom label will be displayed in the circuit diagram when using
draw()@qml.qnode(qml.device("default.qubit")) def circuit(): qml.drawer.label(qml.H(0), "my-h") qml.CNOT([0,1]) return qml.probs()
>>> print(qml.draw(circuit)()) 0: ──H("my-h")─╭●─┤ Probs 1: ────────────╰X─┤ Probs
code/api/pennylane.drawer.label
Download Python script
Download Notebook
View on GitHub