def setUp(self): self.gm = Basis.cast('gm', 4) self.pp = Basis.cast('pp', 4) self.std = Basis.cast('std', 4) self.mxGM = np.array( [[1, 0, 0, 0], [0, 0, 1, 0], [0, -1, 0, 0], [0, 0, 0, 1]], 'complex') self.mxStd = bt.change_basis(self.mxGM, self.gm, self.std) self.mxPP = bt.change_basis(self.mxGM, self.gm, self.pp)
def setUp(self): #Set Model objects to "strict" mode for testing ExplicitOpModel._strict = True # density matrix == 3x3 block diagonal matrix: a 2x2 block followed by a 1x1 block self.stateSpaceDims = [(4, ), (1, )] self.std = Basis.cast('std', 9) self.gm = Basis.cast('gm', 9) self.stdSmall = Basis.cast('std', [4, 1]) self.gmSmall = Basis.cast('gm', [4, 1]) #labels which give a tensor product interp. for the states within each density matrix block self.stateSpaceLabels = [('Qhappy', ), ('Lsad', )] #Build a test gate -- old # X(pi,Qhappy)*LX(pi,0,2) self.testGate = build_operation(self.stateSpaceDims, self.stateSpaceLabels, "LX(pi,0,2)", "std") self.testGateGM_mx = bt.change_basis(self.testGate, self.stdSmall, self.gmSmall) self.expTestGate_mx = bt.flexible_change_basis(self.testGate, self.stdSmall, self.std) self.expTestGateGM_mx = bt.change_basis(self.expTestGate_mx, self.std, self.gm)
def test_convert(self): basis = Basis.cast("pp", 4) conv = sv.convert(self.vec, "static", basis)
def test_raises_on_invalid_conversion_type(self): basis = Basis.cast("pp", 4) with self.assertRaises(ValueError): sv.convert(self.vec, "foobar", basis)
def test_gm_basis(self): #mx_dim = sum([ int(np.sqrt(d)) for d in self.stateSpaceDims]) cmb = Basis.cast('gm', self.stateSpaceDims) self.checkBasis(cmb)