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