class_docstr: Tests for CV integration
class_docstr_tok: ["Tests","for","CV","integration"]
docstr: Test variance of a first order CV observable
docstr_tok: ["Test","variance","of","a","first","order","CV","observable"]
code: def test_first_order_observable(
      self, diff_method, kwargs, interface, tol
  ):
      """Test variance of a first order CV observable"""
      dev = qml.device("default.gaussian", wires=1)
      if diff_method == "spsa":
          kwargs["sampler_rng"] = np.random.default_rng(SEED_FOR_SPSA)
          tol = TOL_FOR_SPSA
  
      r = 0.543
      phi = -0.654
  
      @qnode(
          dev, interface=interface, diff_method=diff_method, **kwargs
      )
      def circuit(r, phi):
          qml.Squeezing(r, 0, wires=0)
          qml.Rotation(phi, wires=0)
          return qml.var(qml.QuadX(0))
  
      res = circuit(r, phi)
      expected = (
          np.exp(2 * r) * np.sin(phi) ** 2
          + np.exp(-2 * r) * np.cos(phi) ** 2
      )
      assert np.allclose(res, expected, atol=tol, rtol=0)
  
      # circuit jacobians
      res = jax.grad(circuit, argnums=[0, 1])(r, phi)
      expected = np.array(
          [
              2 * np.exp(2 * r) * np.sin(phi) ** 2
              - 2 * np.exp(-2 * r) * np.cos(phi) ** 2,
              2 * np.sinh(2 * r) * np.sin(2 * phi),
          ]
      )
      assert np.allclose(res, expected, atol=tol, rtol=0)
  
imports: import pytest
  import pennylane
  from pennylane import numpy
  from pennylane import qnode
  from pennylane.tape import QuantumScript
label_desc: Use image node_id 1 for calling the TestCV obj's underlying member method code with example usage: obj.test_first_order_observable(diff_method, kwargs, interface, tol) and returns: qml