Ejemplo n.º 1
0
 def test_Xgate_displacement(self):
     """Test displacement vector matches Xgate"""
     x = 0.1234
     H, _ = xdisplacement(x)
     _, d = quadratic_coefficients(H)
     expected = np.array([1, 0])
     assert np.allclose(d, expected)
Ejemplo n.º 2
0
 def test_gaussian(self):
     """Test output is gaussian"""
     self.logTestName()
     H, _ = xdisplacement(self.x)
     res = H.is_gaussian()
     self.assertTrue(res)
Ejemplo n.º 3
0
 def test_identity(self):
     """Test alpha=0 gives identity"""
     self.logTestName()
     _, r = xdisplacement(0)
     self.assertEqual(r, 0)
Ejemplo n.º 4
0
 def test_hermitian(self):
     """Test output is hermitian"""
     self.logTestName()
     H, _ = xdisplacement(self.x)
     self.assertTrue(is_hermitian(H))
     self.assertTrue(is_hermitian(get_boson_operator(H, hbar=self.hbar)))
Ejemplo n.º 5
0
 def test_time(self):
     """Test time parameter is correct"""
     self.logTestName()
     _, r = xdisplacement(self.x)
     self.assertEqual(r, self.x)
Ejemplo n.º 6
0
 def test_coefficients(self):
     """Test coefficients are correct"""
     self.logTestName()
     H, _ = xdisplacement(self.x)
     self.assertEqual(H, QuadOperator('p0', 1))
Ejemplo n.º 7
0
 def test_coefficients(self):
     """Test coefficients are correct"""
     H, _ = xdisplacement(self.x)
     assert H == QuadOperator('p0', 1)
Ejemplo n.º 8
0
 def test_time(self):
     """Test time parameter is correct"""
     _, r = xdisplacement(self.x)
     assert r == self.x
Ejemplo n.º 9
0
 def test_gaussian(self):
     """Test output is gaussian"""
     H, _ = xdisplacement(self.x)
     res = H.is_gaussian()
     assert res
Ejemplo n.º 10
0
 def test_hermitian(self, hbar):
     """Test output is hermitian"""
     H, _ = xdisplacement(self.x)
     assert is_hermitian(H)
     assert is_hermitian(get_boson_operator(H, hbar=hbar))
Ejemplo n.º 11
0
 def test_identity(self):
     """Test alpha=0 gives identity"""
     _, r = xdisplacement(0)
     assert r == 0