示例#1
0
    def test_cz_optimize_extract(self):
        qb_no = 8
        c = Circuit(qb_no)
        for i in range(qb_no):
            for j in range(i + 1, qb_no):
                c.add_gate("CZ", i, j)

        g = c.to_graph()
        clifford_simp(g, quiet=True)
        c2 = extract_circuit(g)
        cnot_count = 0
        for gate in c2.gates:
            if isinstance(gate, CNOT):
                cnot_count += 1
        self.assertTrue(cnot_count == 4)
        self.assertTrue(c.verify_equality(c2))
示例#2
0
 def test_verify_equality_permutation_option(self):
     c1 = Circuit(2)
     c2 = Circuit(2)
     c2.add_gate("SWAP", 0, 1)
     self.assertTrue(c1.verify_equality(c2, up_to_swaps=True))
     self.assertFalse(c1.verify_equality(c2, up_to_swaps=False))