diff --git a/abp.py b/abp.py index a1ab2fd..9dafe9b 100644 --- a/abp.py +++ b/abp.py @@ -1,82 +1 @@ -from clifford import * - -""" -Porting Anders and Briegel to Python -""" - -stab_rep = {None: "-", 0: "I", 1: "X", 2: "Y", 3:"Z"} - -class Stabilizer(object): - - def __init__(self, graph): - n = graph.nqubits - self.paulis = [[None for i in range(n)] for j in range(n)] - self.rowsigns = [None for i in range(n)] - - for i in range(n): - self.rowsigns[i] = 0 % 4 - for j in range(n): - if i == j: - self.paulis[i][j] = lco_x - elif j in graph.vertices[i].neighbors: - self.paulis[i][j] = lco_z - else: - self.paulis[i][j] = lco_id - - self.conjugate(i, j, graph.vertices[j].vertex_operator) - - def conjugate(self, i, j, vertex_operator): - self.rowsigns[j] = self.rowsigns[j] + \ - self.paulis[i][j].conjugate(vertex_operator) - - def __str__(self): - return "\n".join(" ".join(stab_rep[x] for x in row) for row in self.paulis) - - -class Vertex(object): - - def __init__(self, index): - self.index = index - self.vertex_operator = lco_h - self.neighbors = set() - - def edgelist(self): - return [set((self.index, n)) for n in self.neighbors] - - def __str__(self): - return "{}".format(", ".join(map(str, self.neighbors))) - - -class GraphRegister(object): - - def __init__(self, n): - self.nqubits = n - self.vertices = [Vertex(i) for i in xrange(n)] - - def add_edge(self, v1, v2): - self.vertices[v1].neighbors.add(v2) - self.vertices[v2].neighbors.add(v1) - - def del_edge(self, v1, v2): - self.vertices[v1].neighbors.remove(v2) - self.vertices[v2].neighbors.remove(v1) - - def toggle_edge(self, v1, v2): - if v2 in self.vertices[v1].neighbors: - self.del_edge(v1, v2) - else: - self.add_edge(v1, v2) - - def edgelist(self): - return map(tuple, frozenset(frozenset((v.index, n)) - for v in self.vertices - for n in v.neighbors)) - - def __str__(self, ): - return "graph:\n"+"\n".join(str(v) for v in self.vertices if len(v.neighbors) > 0) - - -if __name__ == '__main__': - g = GraphRegister(10) - g.toggle_edge(0, 1) - print g +nothing diff --git a/clifford.py b/clifford.py deleted file mode 100644 index 56ea556..0000000 --- a/clifford.py +++ /dev/null @@ -1,18 +0,0 @@ -lco_id = 0 -lco_x = 1 -lco_y = 2 -lco_z = 3 -lco_h = 10 -lco_spiz = 5 -lco_smiz = 6 -lco_spiy = 11 -lco_smiy = 9 -lco_spix = 14 -lco_smix = 15 -lco_s = lco_smiz -lco_sh = lco_spiz - -rp_p1 = 0 -rp_pi = 1 -rp_m1 = 2 -rp_mi = 3 diff --git a/loccliff.py b/loccliff.py deleted file mode 100644 index 1d8add6..0000000 --- a/loccliff.py +++ /dev/null @@ -1,10 +0,0 @@ -NAMES = [" ", "i", "-", "-i"] - -class RightPhase(int): - def __init__(self, phase): - self.ph = phase % 4 - - def get_name(self): - return NAMES[self.ph] - - diff --git a/rightphase.py b/rightphase.py deleted file mode 100644 index f1e8995..0000000 --- a/rightphase.py +++ /dev/null @@ -1,11 +0,0 @@ -NAMES = [" ", "i", "-", "-i"] - -class RightPhase(int): - def __new__(cls, value): - return super(TestClass, cls).__new__(cls, value % 4) - -a = TestClass(2) -b = TestClass(5) -print a, b -print a+b+b - diff --git a/tests/test_graph.py b/tests/test_graph.py deleted file mode 100644 index e498a74..0000000 --- a/tests/test_graph.py +++ /dev/null @@ -1,28 +0,0 @@ -from nose import with_setup -import abp - -def setup(): - global g - g = abp.GraphRegister(10) - -@with_setup(setup) -def test_adding(): - g.add_edge(0,1) - g.add_edge(1,2) - g.toggle_edge(2,0) - g.toggle_edge(2,3) - g.toggle_edge(3,2) - assert(len(g.edgelist()) == 3) - -def setup_stab(): - global g - g = abp.GraphRegister(10) - g.add_edge(0,1) - g.add_edge(1,2) - g.add_edge(2,0) - -@with_setup(setup_stab) -def test_adding(): - s = abp.Stabilizer(g) - - diff --git a/tests/test_loccliff.py b/tests/test_loccliff.py deleted file mode 100644 index 7962217..0000000 --- a/tests/test_loccliff.py +++ /dev/null @@ -1,6 +0,0 @@ -from nose import with_setup -import loccliff - -def test_loccliff(): - pass - diff --git a/tests/test_rightphase.py b/tests/test_rightphase.py deleted file mode 100644 index 6da3b60..0000000 --- a/tests/test_rightphase.py +++ /dev/null @@ -1,6 +0,0 @@ -from nose import with_setup -from rightphase import RightPhase - -def test_rightphase(): - assert RightPhase(4) == 4 - diff --git a/tests/test_stabilizer.py b/tests/test_stabilizer.py deleted file mode 100644 index e69de29..0000000