|
@@ -1,5 +1,8 @@ |
|
|
from abp.graphstate import GraphState |
|
|
from abp.graphstate import GraphState |
|
|
from anders_briegel import graphsim |
|
|
from anders_briegel import graphsim |
|
|
|
|
|
import random |
|
|
|
|
|
import difflib |
|
|
|
|
|
import re |
|
|
|
|
|
|
|
|
def test_1(): |
|
|
def test_1(): |
|
|
N=10 |
|
|
N=10 |
|
@@ -17,3 +20,32 @@ def test_1(): |
|
|
b.act_cz(i, i+1) |
|
|
b.act_cz(i, i+1) |
|
|
|
|
|
|
|
|
assert a.get_adj_list() == b.adj_list() |
|
|
assert a.get_adj_list() == b.adj_list() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_2(): |
|
|
|
|
|
N=10 |
|
|
|
|
|
|
|
|
|
|
|
a = graphsim.GraphRegister(N) |
|
|
|
|
|
b = GraphState() |
|
|
|
|
|
|
|
|
|
|
|
for i in range(N): |
|
|
|
|
|
b.add_vertex(i) |
|
|
|
|
|
|
|
|
|
|
|
for i in range(100): |
|
|
|
|
|
if random.random()>0.5: |
|
|
|
|
|
j = random.randint(0, N-1) |
|
|
|
|
|
a.hadamard(j) |
|
|
|
|
|
b.act_hadamard(j) |
|
|
|
|
|
else: |
|
|
|
|
|
q = random.randint(0, N-2) |
|
|
|
|
|
a.cphase(q, q+1) |
|
|
|
|
|
b.act_cz(q, q+1) |
|
|
|
|
|
|
|
|
|
|
|
aa = a.get_adj_list() |
|
|
|
|
|
bb = b.adj_list() |
|
|
|
|
|
try: |
|
|
|
|
|
assert re.sub("\\s", "", aa) == re.sub("\\s", "", bb) |
|
|
|
|
|
except AssertionError: |
|
|
|
|
|
print aa |
|
|
|
|
|
print bb |
|
|
|
|
|
|