| @@ -1,6 +1,5 @@ | |||||
| import networkx as nx | import networkx as nx | ||||
| from matplotlib import pyplot as plt | from matplotlib import pyplot as plt | ||||
| from vops import * | |||||
| class Graph(object): | class Graph(object): | ||||
| @@ -1,48 +0,0 @@ | |||||
| import networkx as nx | |||||
| from matplotlib import pyplot as plt | |||||
| from vops import * | |||||
| class Graph(object): | |||||
| def __init__(self, n): | |||||
| self.vertices = [set() for i in xrange(n)] | |||||
| self.vops = [hadamard for i in xrange(n)] | |||||
| def add_edge(self, v1, v2): | |||||
| self.vertices[v1].add(v2) | |||||
| self.vertices[v2].add(v1) | |||||
| def del_edge(self, v1, v2): | |||||
| self.vertices[v1].remove(v2) | |||||
| self.vertices[v2].remove(v1) | |||||
| def edgelist(self): | |||||
| edges = frozenset(frozenset((i, n)) | |||||
| for i, v in enumerate(self.vertices) | |||||
| for n in v) | |||||
| return [tuple(e) for e in edges] | |||||
| def draw(self, filename="out.pdf"): | |||||
| g = nx.from_edgelist(self.edgelist()) | |||||
| pos = nx.spring_layout(g) | |||||
| nx.draw_networkx_nodes(g, pos, node_color="white", node_size=1000) | |||||
| nx.draw_networkx_labels(g, pos) | |||||
| nx.draw_networkx_edges(g, pos) | |||||
| for i, vop in enumerate(self.vops): | |||||
| if not i in pos: continue | |||||
| x, y = pos[i] | |||||
| plt.text(x, y+0.1, vops[vop], ha="center") | |||||
| plt.axis('off') | |||||
| plt.savefig(filename) | |||||
| if __name__ == '__main__': | |||||
| g = Graph(10) | |||||
| g.add_edge(0, 1) | |||||
| g.add_edge(1, 3) | |||||
| g.add_edge(3, 2) | |||||
| g.add_edge(3, 0) | |||||
| g.add_edge(2, 0) | |||||
| print g.edgelist() | |||||
| g.draw() | |||||
| @@ -1,31 +0,0 @@ | |||||
| from numpy import * | |||||
| import json | |||||
| #json.load(open("anders_ | |||||
| #i = matrix(eye(2, dtype=complex)) | |||||
| #h = matrix([[1, 1], [1, -1]], dtype=complex) / sqrt(2) | |||||
| #p = matrix([[1, 0], [0, 1j]], dtype=complex) | |||||
| #s_set = [i, p, p*p, p*p*p] | |||||
| #s_names = ["i", "p", "pp", "ppp"] | |||||
| #c_set = [i, h, h*p, h*p*p, h*p*p*p, h*p*p*h] | |||||
| #c_names = ["i", "h", "hp", "hpp", "hppp", "hpph"] | |||||
| #names = [] | |||||
| #matrices = [] | |||||
| #for s, s_name in zip(s_set, s_names): | |||||
| #for c, c_name in zip(c_set, c_names): | |||||
| #names.append(s_name+c_name) | |||||
| #matrices.append(s*c) | |||||
| #print " ".join(names) | |||||
| #print len(names) | |||||
| #for m in matrices: | |||||
| # print (m/abs(amax(m))).round(0).reshape(4) | |||||
| #print average(abs(array((m/abs(amax(m))).round(0).reshape(4).tolist()[0]))) | |||||
| @@ -1,4 +1,4 @@ | |||||
| import local_cliffords as lc | |||||
| import clifford as lc | |||||
| from numpy import * | from numpy import * | ||||
| def test_identify_pauli(): | def test_identify_pauli(): | ||||
| @@ -1,14 +0,0 @@ | |||||
| class LocCliffOp: | |||||
| def __init__(self, op): | |||||
| self.op = op | |||||
| self.name = names[op] | |||||
| def __str__(self): | |||||
| return self.name | |||||
| if __name__ == '__main__': | |||||
| l = LocCliffOp(0) | |||||
| print l | |||||