class_docstr: Tests for weighted random Hamiltonian term sampling
docstr: Checks that an exception is raised if the term sampling method is unknown
docstr_tok: ["Checks","that","an","exception","is","raised","if","the","term","sampling","method","is","unknown"]
code: def test_unknown_term_sampling_method(self):
      """Checks that an exception is raised if the term sampling method is unknown"""
      coeffs = [0.2, 0.1]
      dev = qml.device("default.qubit", wires=2, shots=100)
      H = qml.Hamiltonian(
          coeffs, [qml.PauliZ(0), qml.PauliZ(0) @ qml.PauliZ(1)]
      )
  
      @qml.qnode(dev)
      def circuit(weights):
          qml.StronglyEntanglingLayers(weights, wires=range(2))
          return qml.expval(H)
  
      weights = np.random.random(
          qml.templates.StronglyEntanglingLayers.shape(3, 2)
      )
  
      opt = qml.ShotAdaptiveOptimizer(
          min_shots=10, term_sampling="uniform_random_sampling"
      )
  
      with pytest.raises(
          ValueError, match="Unknown Hamiltonian term sampling method"
      ):
          opt.step(circuit, weights)
  
imports: import pytest
  from flaky import flaky
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 4 for calling the TestQNodeWeightedRandomSampling obj's underlying member method code with example usage: obj.test_unknown_term_sampling_method() and returns: qml