Пример #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)
Пример #2
0
 def test_gaussian(self):
     """Test output is gaussian"""
     self.logTestName()
     H, _ = xdisplacement(self.x)
     res = H.is_gaussian()
     self.assertTrue(res)
Пример #3
0
 def test_identity(self):
     """Test alpha=0 gives identity"""
     self.logTestName()
     _, r = xdisplacement(0)
     self.assertEqual(r, 0)
Пример #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)))
Пример #5
0
 def test_time(self):
     """Test time parameter is correct"""
     self.logTestName()
     _, r = xdisplacement(self.x)
     self.assertEqual(r, self.x)
Пример #6
0
 def test_coefficients(self):
     """Test coefficients are correct"""
     self.logTestName()
     H, _ = xdisplacement(self.x)
     self.assertEqual(H, QuadOperator('p0', 1))
Пример #7
0
 def test_coefficients(self):
     """Test coefficients are correct"""
     H, _ = xdisplacement(self.x)
     assert H == QuadOperator('p0', 1)
Пример #8
0
 def test_time(self):
     """Test time parameter is correct"""
     _, r = xdisplacement(self.x)
     assert r == self.x
Пример #9
0
 def test_gaussian(self):
     """Test output is gaussian"""
     H, _ = xdisplacement(self.x)
     res = H.is_gaussian()
     assert res
Пример #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))
Пример #11
0
 def test_identity(self):
     """Test alpha=0 gives identity"""
     _, r = xdisplacement(0)
     assert r == 0