class_docstr: Tests for parameter gradient methods
docstr: Test that a non-Gaussian operation succeeding
  a differentiable Gaussian operation results in
  numeric differentiation.
docstr_tok: ["Test","that","a","non-Gaussian","operation","succeeding","a","differentiable","Gaussian","operation","results","in","numeric","differentiation","."]
code: def test_non_gaussian_operation(self):
      """Test that a non-Gaussian operation succeeding
      a differentiable Gaussian operation results in
      numeric differentiation."""
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.Rotation(1.0, wires=[0])
          qml.Rotation(1.0, wires=[1])
          # Non-Gaussian
          qml.Kerr(1.0, wires=[1])
          qml.expval(qml.QuadP(0))
          qml.expval(qml.QuadX(1))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      # First rotation gate has no succeeding non-Gaussian operation
      assert _grad_method_cv(tape, 0) == "A"
      # Second rotation gate does no succeeding non-Gaussian operation
      assert _grad_method_cv(tape, 1) == "F"
      # Kerr gate does not support the parameter-shift rule
      assert _grad_method_cv(tape, 2) == "F"
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.Rotation(1.0, wires=[0])
          qml.Rotation(1.0, wires=[1])
          # entangle the modes
          qml.Beamsplitter(1.0, 0.0, wires=[0, 1])
          # Non-Gaussian
          qml.Kerr(1.0, wires=[1])
          qml.expval(qml.QuadP(0))
          qml.expval(qml.QuadX(1))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      # After entangling the modes, the Kerr gate now succeeds
      # both initial rotations
      assert _grad_method_cv(tape, 0) == "F"
      assert _grad_method_cv(tape, 1) == "F"
      assert _grad_method_cv(tape, 2) == "F"
  
imports: import unittest.mock
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.gradients import param_shift_cv
  from pennylane.gradients.gradient_transform import choose_trainable_params
  from pennylane.gradients.parameter_shift_cv import _grad_method_cv, _find_gradient_methods_cv, _transform_observable
label_desc: Use image node_id 4 for calling the TestGradAnalysis obj's underlying member method code with example usage: obj.test_non_gaussian_operation() without return types