Example #1
0
    def test_sparse_basis(self):
        sparsePP = Basis("pp",2,sparse=True)
        sparsePP2 = Basis("pp",2,sparse=True)
        sparseBlockPP = Basis("pp",[2,2],sparse=True)
        sparsePP_2Q = Basis("pp",4,sparse=True)
        sparseGM_2Q = Basis("gm",2,sparse=True) #different sparsity structure than PP 2Q
        denseGM = Basis("gm",2,sparse=False)
        
        mxs = sparsePP.get_composite_matrices()
        block_mxs = sparseBlockPP.get_composite_matrices()

        expeq = sparsePP.expanded_equivalent()
        block_expeq = sparseBlockPP.expanded_equivalent()

        raw_mxs = bt.basis_matrices("pp",2,sparse=True)
        
        #test equality of bases with other bases and matrices
        self.assertEqual(sparsePP, sparsePP2)
        self.assertEqual(sparsePP, raw_mxs)
        self.assertNotEqual(sparsePP, sparsePP_2Q)
        self.assertNotEqual(sparsePP_2Q, sparseGM_2Q)

        #sparse transform matrix
        trans = sparsePP.transform_matrix(sparsePP2)
        self.assertArraysAlmostEqual(trans, np.identity(4,'d'))
        trans2 = sparsePP.transform_matrix(denseGM)

        #test equality for large bases, which is too expensive so it always returns false
        large_sparsePP = Basis("pp",16,sparse=True)
        large_sparsePP2 = Basis("pp",16,sparse=True)
        self.assertNotEqual(large_sparsePP, large_sparsePP2)
Example #2
0
    def test_basis_object(self):
        #test a few aspects of a Basis object that other tests miss...
        b = Basis("pp",2)
        beq = b.expanded_equivalent()
        longnm = bt.basis_longname(b)
        lbls = bt.basis_element_labels(b)

        raw_mxs = bt.basis_matrices("pp",2)
        with self.assertRaises(NotImplementedError):
            bt.basis_matrices("foobar",2) #invalid basis name

        print("Dim = ", repr(b.dim) ) # calls Dim.__repr__