class_docstr: Gate tests.
class_docstr_tok: ["Gate","tests","."]
docstr: Test the quadratic phase symplectic transform.
docstr_tok: ["Test","the","quadratic","phase","symplectic","transform","."]
code: def test_quadratic_phase(self, tol):
      """Test the quadratic phase symplectic transform."""
  
      s = 0.543
      S = quadratic_phase(s)
  
      # apply to a coherent state. P[x, p] -> [x, p+sx]
      alpha = 0.23 + 0.12j
      out = S @ np.array([alpha.real, alpha.imag]) * np.sqrt(2 * hbar)
      expected = np.array(
          [alpha.real, alpha.imag + s * alpha.real]
      ) * np.sqrt(2 * hbar)
      assert out == pytest.approx(expected, abs=tol)
  
imports: import numpy
  import numpy.random
  import pytest
  from scipy.linalg import block_diag
  from scipy.special import factorial
  import pennylane
  from pennylane import DeviceError
  from pennylane.devices.default_gaussian import fock_prob, rotation, squeezing, quadratic_phase, beamsplitter, two_mode_squeezing, controlled_addition, controlled_phase, vacuum_state, coherent_state, squeezed_state, displaced_squeezed_state, thermal_state
  from pennylane.wires import Wires
label_desc: Use image node_id 4 for calling the TestGates obj's underlying member method code with example usage: obj.test_quadratic_phase(tol) without return types