class_docstr: Tests for the custom_decomps argument for devices
class_docstr_tok: ["Tests","for","the","custom_decomps","argument","for","devices"]
docstr: Test that the custom_decomps dictionary accepts both strings and operator classes as keys.
docstr_tok: ["Test","that","the","custom_decomps","dictionary","accepts","both","strings","and","operator","classes","as","keys","."]
code: def test_string_and_operator_allowed(self, device_name):
      """Test that the custom_decomps dictionary accepts both strings and operator classes as keys."""
  
      custom_decomps = {
          "Hadamard": custom_hadamard,
          qml.CNOT: custom_cnot,
      }
      decomp_dev = qml.device(
          device_name, wires=2, custom_decomps=custom_decomps
      )
  
      @qml.qnode(decomp_dev, expansion_strategy="device")
      def circuit():
          qml.Hadamard(wires=0)
          qml.CNOT(wires=[0, 1])
          return qml.expval(qml.PauliZ(0))
  
      _ = circuit()
      decomp_ops = circuit.tape.operations
  
      assert len(decomp_ops) == 7
      for op in decomp_ops:
          assert op.name != "Hadamard"
          assert op.name != "CNOT"
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.wires import Wires
label_desc: Use image node_id 1 for calling the TestCreateCustomDecompExpandFn obj's underlying member method code with example usage: obj.test_string_and_operator_allowed(device_name) and returns: qml