class_docstr: Test dunder and other visualizing methods.
class_docstr_tok: ["Test","dunder","and","other","visualizing","methods","."]
docstr: Test label method.
docstr_tok: ["Test","label","method","."]
code: def test_label(self):
      """Test label method."""
      op = ValidOp(qml.RY(1, wires=1), qml.PauliX(1))
      assert op.label() == "RY#X"
      with pytest.raises(ValueError):
          op.label(base_label=["only_first"])
  
      nested_op = ValidOp(qml.PauliX(0), op)
      assert nested_op.label() == "X#(RY#X)"
      assert nested_op.label(decimals=2) == "X#(RY\n(1.00)#X)"
      assert (
          nested_op.label(base_label=["x0", ["ry", "x1"]])
          == "x0#(ry#x1)"
      )
  
      U = np.array([[1, 0], [0, -1]])
      cache = {"matrices": []}
      op = ValidOp(
          qml.PauliX(0),
          ValidOp(qml.PauliY(1), qml.QubitUnitary(U, wires=0)),
      )
      assert op.label(cache=cache) == "X#(Y#U(M0))"
      assert cache["matrices"] == [U]
  
imports: from copy import copy
  import numpy
  import pytest
  import pennylane
  from pennylane.operation import DecompositionUndefinedError
  from pennylane.ops.op_math import CompositeOp, Prod, Sum, SProd
  from pennylane.wires import Wires
label_desc: Use image node_id 3 for calling the TestMscMethods obj's underlying member method code with example usage: obj.test_label() without return types