From 0d78f792c2cfb65f7a7f12c87d3cd0d94dae1c20 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Fri, 27 May 2016 17:35:48 +0100 Subject: [PATCH] Prepare for JS tests --- abp/server.py | 2 +- scripts/investigate_rightphase.py | 13 ------------ scripts/try_stabilizing.py | 21 ------------------- scripts/wtf.py | 35 ------------------------------- scripts/wtf2.py | 32 ---------------------------- static/scripts/graph.js | 4 ++++ 6 files changed, 5 insertions(+), 102 deletions(-) delete mode 100644 scripts/investigate_rightphase.py delete mode 100644 scripts/try_stabilizing.py delete mode 100644 scripts/wtf.py delete mode 100644 scripts/wtf2.py diff --git a/abp/server.py b/abp/server.py index e154e5d..a0f909b 100644 --- a/abp/server.py +++ b/abp/server.py @@ -7,7 +7,7 @@ import webbrowser clients = [] def new_message(client, server, message): - print "Receieved update from client {}.".format(client["id"]) + print "Received update from client {}.".format(client["id"]) server.send_message_to_all(message) def new_client(client, server): diff --git a/scripts/investigate_rightphase.py b/scripts/investigate_rightphase.py deleted file mode 100644 index daca21d..0000000 --- a/scripts/investigate_rightphase.py +++ /dev/null @@ -1,13 +0,0 @@ -from anders_briegel import graphsim -from abp import clifford, qi -import itertools -import numpy as np - -for i, j in itertools.product(range(4), range(24)): - operation, phase = clifford.conjugate(i, j) - vop_u = clifford.unitaries[i] - transform_u = clifford.unitaries[j] - u = np.dot(transform_u, np.dot(vop_u, qi.hermitian_conjugate(transform_u))) - #print u.round(2) - - diff --git a/scripts/try_stabilizing.py b/scripts/try_stabilizing.py deleted file mode 100644 index 450d360..0000000 --- a/scripts/try_stabilizing.py +++ /dev/null @@ -1,21 +0,0 @@ -import abp -import numpy as np -from anders_briegel import graphsim - -def wah(): - N = 10 - a = graphsim.GraphRegister(N) - - for i in range(1000): - if np.random.random()>0.5: - j = np.random.randint(0, N-1) - a.hadamard(j) - else: - q = np.random.randint(0, N-2) - a.cphase(q, q+1) - - a.print_stabilizer() - - -u = abp.GraphState(xrange(2)) -print u.to_stabilizer() diff --git a/scripts/wtf.py b/scripts/wtf.py deleted file mode 100644 index ac002e0..0000000 --- a/scripts/wtf.py +++ /dev/null @@ -1,35 +0,0 @@ -from abp import clifford, qi, GraphState -from anders_briegel import graphsim -import numpy as np -import itertools as it - - -""" This is an example of where we get a discrepancy """ - -def pete(): - a = GraphState(xrange(3)) - a.act_hadamard(0) - a.act_hadamard(1) - a.act_hadamard(2) - a.act_cz(0, 1) - a.act_cz(0, 2) - a.act_local_rotation(0, 1) - a.act_local_rotation(2, 3) - a.act_cz(1,2) - return a.adj_list() - -def anders(): - b = graphsim.GraphRegister(3) - b.hadamard(0) - b.hadamard(1) - b.hadamard(2) - b.cphase(0, 1) - b.cphase(0, 2) - b.local_op(0, graphsim.LocCliffOp(1)) - b.local_op(2, graphsim.LocCliffOp(3)) - b.cphase(1,2) - b.print_adj_list() - -pete() -anders() - diff --git a/scripts/wtf2.py b/scripts/wtf2.py deleted file mode 100644 index eec1450..0000000 --- a/scripts/wtf2.py +++ /dev/null @@ -1,32 +0,0 @@ -from abp import GraphState -from anders_briegel import graphsim -from abp import clifford -import random, difflib, re -from copy import deepcopy - - -def isequal(a, b): - """ TODO: Sketchy as you like. Remove this abomination """ - aa = a.get_adj_list() - bb = b.adj_list() - return re.sub("\\s", "", aa) == re.sub("\\s", "", bb) - -clifford.use_old_cz() - -N = 3 - -a = graphsim.GraphRegister(N) -b = GraphState(range(N)) -previous_state, previous_cz = None, None -while isequal(a, b): - 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) - if a!=b: - a.cphase(q, q+1) - b.act_cz(q, q+1) - - diff --git a/static/scripts/graph.js b/static/scripts/graph.js index 2133ee7..76bbdea 100644 --- a/static/scripts/graph.js +++ b/static/scripts/graph.js @@ -41,3 +41,7 @@ graph.update = function(newState) { gui.render(); }; +graph.test = function(command) { + //Act the command + //Send it back to the server, ultimately thru to python +};