class_docstr: Tests of the automatic gradient method for CV circuits.
class_docstr_tok: ["Tests","of","the","automatic","gradient","method","for","CV","circuits","."]
docstr: Tests that the automatic gradient of a phase space displacement is correct.
docstr_tok: ["Tests","that","the","automatic","gradient","of","a","phase","space","displacement","is","correct","."]
code: def test_displacement_gradient(self, mag, theta, grad_fn_D, tol):
      "Tests that the automatic gradient of a phase space displacement is correct."
  
      # alpha = mag * np.exp(1j * theta)
      autograd_val = grad_fn_D(mag, theta)
      # qfunc evalutes to hbar * Re(alpha)
      manualgrad_val = hbar * np.cos(theta)
      assert autograd_val == pytest.approx(manualgrad_val, abs=tol)
  
imports: import pytest
  import autograd
  import numpy
  import pennylane.numpy
  import pennylane
label_desc: Use image node_id 3 for calling the TestCVGradient obj's underlying member method code with example usage: obj.test_displacement_gradient(mag, theta, grad_fn_D, tol) without return types