Ejemplo n.º 1
0
 def test_IndexProduct_exceptions(self):
     for low, high in [(1, 0), (0, self.L - 1), (0, self.L), (-1, 0)]:
         with self.subTest(low=low, high=high):
             d = do.Sigmay(index=0) * do.Sigmay(index=1)
             d.L = self.L
             with self.assertRaises(ValueError):
                 do.IndexProduct(d, min_i=low, max_i=high)
Ejemplo n.º 2
0
    def test_Majorana(self):
        tests = [(1, do.Sigmay()), (2, do.Sigmaz(0) * do.Sigmax(1)),
                 (4, do.Sigmaz(0) * do.Sigmaz(1) * do.Sigmax(2))]

        for idx, op in tests:
            X = Majorana(idx)
            self.assertEqual(X, op)
Ejemplo n.º 3
0
 def test_IndexSum_edgelimits(self):
     for i in range(self.L):
         with self.subTest(ind=i):
             d = do.IndexSum(do.Sigmay(L=self.L), min_i=i, max_i=i)
             n = np_sigmay(i, self.L)
             r, msg = check_dnm_np(d, n)
             self.assertTrue(r, msg=msg)
Ejemplo n.º 4
0
 def test_length(self):
     x = do.Sigmax()
     y = do.Sigmay()
     x.L = 1
     y.L = 2
     with self.assertRaises(ValueError):
         x + y
Ejemplo n.º 5
0
 def test_IndexSum_limits(self):
     for low, high in [(1, 1), (1, 3), (0, 3), (0, 0)]:
         with self.subTest(low=low, high=high):
             d = do.Sigmay(L=self.L)
             d = do.IndexSum(d, min_i=low, max_i=high)
             n = np_sigmay(low, self.L)
             for i in range(low + 1, high + 1):
                 n += np_sigmay(i, self.L)
             r, msg = check_dnm_np(d, n)
             self.assertTrue(r, msg=msg)
Ejemplo n.º 6
0
 def test_commutator(self):
     self.assertEqual(commutator(do.Sigmax(), do.Sigmay()),
                      2j * do.Sigmaz())
Ejemplo n.º 7
0
 def test_IndexSum_exceptions(self):
     for low, high in [(1, 0), (0, self.L + 1), (-1, 0)]:
         with self.subTest(low=low, high=high):
             d = do.Sigmay(L=self.L)
             with self.assertRaises(ValueError):
                 do.IndexSum(d, min_i=low, max_i=high)