Beispiel #1
0
 def test_coherent_state(self):
     """Test the coherent state is correct."""
     self.logTestName()
     a = 0.432-0.123j
     means, cov = coherent_state(a, hbar=hbar)
     self.assertAllAlmostEqual(means, np.array([a.real, a.imag])*np.sqrt(2*hbar), delta=self.tol)
     self.assertAllAlmostEqual(cov, np.identity(2)*hbar/2, delta=self.tol)
Beispiel #2
0
 def test_coherent_state(self, tol):
     """Test the coherent state is correct."""
     a = 0.432 - 0.123j
     means, cov = coherent_state(a, hbar=hbar)
     assert means == pytest.approx(np.array([a.real, a.imag]) *
                                   np.sqrt(2 * hbar),
                                   abs=tol)
     assert cov == pytest.approx(np.identity(2) * hbar / 2, abs=tol)