class_docstr: Test exceptions are raised for incorrect usage
docstr: Test that an exception is raised if an analytic device is used
docstr_tok: ["Test","that","an","exception","is","raised","if","an","analytic","device","is","used"]
code: def test_analytic_device_error(self):
      """Test that an exception is raised if an analytic device is used"""
      H = qml.Hamiltonian([0.3, 0.1], [qml.PauliX(0), qml.PauliZ(0)])
      dev = qml.device("default.qubit", wires=1, shots=None)
  
      def ansatz(x):
          qml.RX(x, wires=0)
  
      expval_cost = catch_warn_ExpvalCost(ansatz, H, dev)
  
      opt = qml.ShotAdaptiveOptimizer(min_shots=10)
  
      x = np.array(0.5, requires_grad=True)
  
      # test expval cost
      with pytest.raises(
          ValueError, match="can only be used with devices that"
      ):
          opt.step(expval_cost, x)
  
      # test qnode cost
      with pytest.raises(
          ValueError, match="can only be used with devices that"
      ):
          opt.step(expval_cost.qnodes[0], x)
  
imports: import pytest
  from flaky import flaky
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 1 for calling the TestExceptions obj's underlying member method code with example usage: obj.test_analytic_device_error() without return types