class_docstr: State tests.
class_docstr_tok: ["State","tests","."]
docstr: Test the displaced squeezed state is correct.
docstr_tok: ["Test","the","displaced","squeezed","state","is","correct","."]
code: def test_displaced_squeezed_state(self, tol):
      """Test the displaced squeezed state is correct."""
      alpha = 0.541 + 0.109j
      a = abs(alpha)
      phi_a = np.angle(alpha)
      r = 0.432
      phi_r = 0.123
      cov, means = displaced_squeezed_state(
          a, phi_a, r, phi_r, hbar=hbar
      )
  
      # test vector of means is correct
      assert means == pytest.approx(
          np.array([alpha.real, alpha.imag]) * np.sqrt(2 * hbar),
          abs=tol,
      )
  
      R = rotation(phi_r / 2)
      expected = (
          R
          @ np.array([[np.exp(-2 * r), 0], [0, np.exp(2 * r)]])
          * hbar
          / 2
          @ R.T
      )
      # test covariance matrix is correct
      assert cov == 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 TestStates obj's underlying member method code with example usage: obj.test_displaced_squeezed_state(tol) without return types