Exemplo n.º 1
0
 def test_basis_longname(self):
     longnames = {bt.basis_longname(b) for b in {'gm', 'std', 'pp', 'qt'}}
     self.assertEqual(
         longnames, {
             'Gell-Mann basis', 'Matrix-unit basis', 'Pauli-Product basis',
             'Qutrit basis'
         })
     with self.assertRaises(KeyError):
         bt.basis_longname('not a basis')
Exemplo n.º 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__
Exemplo n.º 3
0
    def test_basis_object(self):
        # test a few aspects of a Basis object that other tests miss...
        b = basis.Basis.cast("pp", 4)
        beq = b.simple_equivalent()
        longnm = bt.basis_longname(b)
        lbls = bt.basis_element_labels(b, None)

        raw_mxs = bt.basis_matrices("pp", 4)
        # TODO assert correctness for all

        with self.assertRaises(AssertionError):
            bt.basis_matrices("foobar", 4)  # invalid basis name

        print("Dim = ", repr(b.dim))  # calls Dim.__repr__
Exemplo n.º 4
0
 def test_basis_longname(self):
     longnames = {basistools.basis_longname(basis) for basis in {'gm', 'std', 'pp'}}
     self.assertEqual(longnames, {'Gell-Mann', 'Matrix-unit', 'Pauli-prod'})
     self.assertEqual(basistools.basis_longname('not a basis'), '?Unknown?')