Ejemplo n.º 1
0
    def test_eq(self):
        s = 1.0
        i = Idx(0, "occ")
        j = Idx(1, "occ")
        sums = [Sigma(i), Sigma(j)]
        tensors = [Tensor([i, j], 'f')]
        t1 = ATerm(s, sums, tensors)
        t0 = t1.copy()
        sums = [Sigma(i), Sigma(j)]
        tensors = [Tensor([j, i], 'f'), Tensor([i, j], 'g')]
        t2 = ATerm(s, sums, tensors)
        sums = [Sigma(i)]
        tensors = [Tensor([i, j], 'f')]
        t3 = ATerm(s, sums, tensors)
        sums = [Sigma(i)]
        tensors = [Tensor([i, j], 'g')]
        t4 = ATerm(s, sums, tensors)

        self.assertTrue(t1 < t2)
        self.assertTrue(t1 != t2)
        self.assertFalse(t0 < t1)
        self.assertTrue(t0 <= t1)
        self.assertTrue(t0 >= t1)
        self.assertTrue(t1 > t3)
        self.assertTrue(t3 < t4)
Ejemplo n.º 2
0
    def test_mul(self):
        s = 1
        i = Idx(0, "occ")
        j = Idx(1, "occ")
        sums = [Sigma(i), Sigma(j)]
        tensors = [Tensor([i, j], 'f')]
        t1 = ATerm(s, sums, tensors)
        t2 = t1.copy()
        out = t1 * t2

        k = Idx(2, "occ")
        l = Idx(3, "occ")
        sumsx = [Sigma(i), Sigma(j), Sigma(k), Sigma(l)]
        tensorsx = [Tensor([i, j], 'f'), Tensor([k, l], 'f')]
        tx = ATerm(s, sumsx, tensorsx)
        self.assertTrue(tx == out)
        tx.scalar = 2
        out = 2 * out
        self.assertTrue(tx == out)
        self.assertTrue(4 * tx == out * 4)