def test_squeezed_state(self, tol): """Test the squeezed state is correct.""" r = 0.432 phi = 0.123 means, cov = squeezed_state(r, phi, hbar=hbar) # test vector of means is zero assert means == pytest.approx(np.zeros([2]), abs=tol) R = rotation(phi/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)
def test_squeezed_state(self): """Test the squeezed state is correct.""" self.logTestName() r = 0.432 phi = 0.123 means, cov = squeezed_state(r, phi, hbar=hbar) # test vector of means is zero self.assertAllAlmostEqual(means, np.zeros([2]), delta=self.tol) R = rotation(phi / 2) expected = R @ np.array([[np.exp(-2 * r), 0], [0, np.exp(2 * r)] ]) * hbar / 2 @ R.T # test covariance matrix is correct self.assertAllAlmostEqual(cov, expected, delta=self.tol)