class_docstr: Tests for the ``adjoint_jacobian`` method
class_docstr_tok: ["Tests","for","the","``","adjoint_jacobian","``","method"]
docstr: Test that the gradient of the RY gate matches the exact analytic formula.
docstr_tok: ["Test","that","the","gradient","of","the","RY","gate","matches","the","exact","analytic","formula","."]
code: def test_ry_gradient(self, tol, dev):
      """Test that the gradient of the RY gate matches the exact analytic formula."""
  
      par = 0.23
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.RY(par, wires=[0])
          qml.expval(qml.PauliX(0))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      tape.trainable_params = {0}
  
      # gradients
      exact = np.cos(par)
      tapes, fn = qml.gradients.finite_diff(tape)
      grad_F = fn(qml.execute(tapes, dev, None))
      grad_A = dev.adjoint_jacobian(tape)
  
      # different methods must agree
      assert isinstance(grad_A, np.ndarray) and grad_A.shape == ()
      assert np.allclose(grad_F, exact, atol=tol, rtol=0)
      assert np.allclose(grad_A, exact, atol=tol, rtol=0)
  
imports: import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 9 for calling the TestAdjointJacobian obj's underlying member method code with example usage: obj.test_ry_gradient(tol, dev) without return types