class_docstr: Tests for weighted random Hamiltonian term sampling
docstr: Checks that cost functions that are expval costs can
  disable use of weighted random sampling
docstr_tok: ["Checks","that","cost","functions","that","are","expval","costs","can","disable","use","of","weighted","random","sampling"]
code: def test_wrs_disabled(self, mocker):
      """Checks that cost functions that are expval costs can
      disable use of weighted random sampling"""
      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)]
      )
  
      expval_cost = catch_warn_ExpvalCost(
          qml.templates.StronglyEntanglingLayers, H, dev
      )
      weights = np.random.random(
          qml.templates.StronglyEntanglingLayers.shape(3, 2)
      )
  
      opt = qml.ShotAdaptiveOptimizer(min_shots=10, term_sampling=None)
      spy = mocker.spy(opt, "weighted_random_sampling")
  
      opt.step(expval_cost, weights)
      spy.assert_not_called()
  
imports: import pytest
  from flaky import flaky
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 2 for calling the TestWeightedRandomSampling obj's underlying member method code with example usage: obj.test_wrs_disabled(mocker) without return types