def test_compose(self): random.seed(SEED) circ1 = cliffords(3, 15) circ2 = cliffords(3, 20) t1 = tensorfy(circ1) t2 = tensorfy(circ2) comp1 = compose_tensors(t1, t2) circ1.compose(circ2) comp2 = tensorfy(circ1) self.assertTrue(compare_tensors(comp1, comp2))
def test_adjoint(self): random.seed(SEED) circ = cliffords(3, 16) t = tensorfy(circ) t_adj = adjoint(t) circ_adj = tensorfy(circ.adjoint()) self.assertTrue(compare_tensors(t_adj, circ_adj))
def test_cliffords_preserves_graph_semantics(self): random.seed(SEED) g = cliffords(5,30) c = Circuit.from_graph(g) g2 = c.to_graph() t = tensorfy(g) t2 = tensorfy(g2) self.assertTrue(compare_tensors(t,t2))
def test_clifford_extract(self): random.seed(SEED) tests = 0 tries = 0 while True: tries += 1 circ = cliffords(5,70) clifford_simp(circ,quiet=True) circ.normalise() if circ.depth()>3: continue # It is not in normal form, so skip this one tests += 1 with self.subTest(test=tests,tries=tries): t = tensorfy(circ) clifford_extract(circ,1,2) t2 = tensorfy(circ) self.assertTrue(compare_tensors(t,t2)) if tests>5: break