qp.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 = qp.X(0) >>> labelled_op = qp.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()@qp.qnode(qp.device("default.qubit")) def circuit(): qp.drawer.label(qp.H(0), "my-h") qp.CNOT([0,1]) return qp.probs()
>>> print(qp.draw(circuit)()) 0: ──H("my-h")─╭●─┤ Probs 1: ────────────╰X─┤ Probs
code/api/pennylane.drawer.label
Download Python script
Download Notebook
View on GitHub