@@ -1 +0,0 @@ | |||||
#TODO: this will serve an in-memory state for visualization etc in the browser |
@@ -0,0 +1,14 @@ | |||||
<!DOCTYPE html> | |||||
<html lang="en"> | |||||
<head> | |||||
<meta charset="utf-8"> | |||||
<title>Title</title> | |||||
<link rel="stylesheet" href="main.css"> | |||||
</head> | |||||
<body> | |||||
<script src="main.js"></script> | |||||
Watching server on localhost:8000 | |||||
</body> | |||||
</html> |
@@ -0,0 +1,3 @@ | |||||
body{ | |||||
font-family: monospace; | |||||
} |
@@ -0,0 +1,20 @@ | |||||
function poll() { | |||||
console.log("polling"); | |||||
var xhr = new XMLHttpRequest(); | |||||
xhr.load=function() { | |||||
console.log(JSON.parse(xhr.responseText)); | |||||
}; | |||||
xhr.onerror = function(e){ | |||||
console.log(e); | |||||
}; | |||||
xhr.open("GET", "/state", true); | |||||
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); | |||||
xhr.send(); | |||||
} | |||||
window.onload = function () { | |||||
console.log("booting"); | |||||
setInterval(poll, 1000); | |||||
} |
@@ -0,0 +1,27 @@ | |||||
import urlparse | |||||
from BaseHTTPServer import BaseHTTPRequestHandler | |||||
from SimpleHTTPServer import SimpleHTTPRequestHandler | |||||
import SocketServer | |||||
class MyHandler(SimpleHTTPRequestHandler): | |||||
def __init__(self, *args, **kwargs): | |||||
SimpleHTTPRequestHandler.__init__(self, *args, **kwargs) | |||||
def get_state(self): | |||||
self.send_response(200) | |||||
self.end_headers() | |||||
self.wfile.write("here is the state") | |||||
def do_GET(self, *args, **kwargs): | |||||
parsed_path = urlparse.urlparse(self.path) | |||||
if parsed_path == "/state": | |||||
return self.get_state() | |||||
else: | |||||
return SimpleHTTPRequestHandler.do_GET(self, *args, **kwargs) | |||||
httpd = SocketServer.TCPServer(("", 8000), MyHandler) | |||||
print "Go to 127.0.0.0:8000" | |||||
httpd.serve_forever() |
@@ -66,16 +66,19 @@ def test_times_table(): | |||||
""" Check the times table """ | """ Check the times table """ | ||||
assert clifford.times_table[0][4] == 4 | assert clifford.times_table[0][4] == 4 | ||||
def test_cz_table_is_symmetric(): | def test_cz_table_is_symmetric(): | ||||
""" Test the CZ table is symmetric """ | """ Test the CZ table is symmetric """ | ||||
for bond, (a, b) in it.product([0, 1], it.combinations(xrange(24), 2)): | for bond, (a, b) in it.product([0, 1], it.combinations(xrange(24), 2)): | ||||
_, a1, a2 = clifford.cz_table[bond, a, b] | |||||
_, a1, a2 = clifford.cz_table[bond, a, b] | |||||
_, b1, b2 = clifford.cz_table[bond, b, a] | _, b1, b2 = clifford.cz_table[bond, b, a] | ||||
assert (a1,a2) == (b2, b1) | |||||
assert (a1, a2) == (b2, b1) | |||||
def test_cz_table_makes_sense(): | def test_cz_table_makes_sense(): | ||||
""" Test the CZ table is symmetric """ | """ Test the CZ table is symmetric """ | ||||
hadamard = clifford.by_name["hadamard"] | hadamard = clifford.by_name["hadamard"] | ||||
assert all(clifford.cz_table[0, 0, 0] == [1, 0, 0]) | assert all(clifford.cz_table[0, 0, 0] == [1, 0, 0]) | ||||
assert all(clifford.cz_table[1, 0, 0] == [0, 0, 0]) | assert all(clifford.cz_table[1, 0, 0] == [0, 0, 0]) | ||||
assert all(clifford.cz_table[0, hadamard, hadamard] == [0, hadamard, hadamard]) | |||||
assert all( | |||||
clifford.cz_table[0, hadamard, hadamard] == [0, hadamard, hadamard]) |
@@ -41,13 +41,13 @@ def test_remove_vop(): | |||||
""" Test that removing VOPs really works """ | """ Test that removing VOPs really works """ | ||||
g = demograph() | g = demograph() | ||||
g.remove_vop(0, 1) | g.remove_vop(0, 1) | ||||
#assert g.vops[0] == lc.by_name["identity"] | |||||
assert g.vops[0] == clifford.by_name["identity"] | |||||
g.remove_vop(1, 1) | g.remove_vop(1, 1) | ||||
#assert g.vops[1] == lc.by_name["identity"] | |||||
assert g.vops[1] == clifford.by_name["identity"] | |||||
g.remove_vop(2, 1) | g.remove_vop(2, 1) | ||||
#assert g.vops[2] == lc.by_name["identity"] | |||||
assert g.vops[2] == clifford.by_name["identity"] | |||||
g.remove_vop(0, 1) | g.remove_vop(0, 1) | ||||
#assert g.vops[0] == lc.by_name["identity"] | |||||
assert g.vops[0] == clifford.by_name["identity"] | |||||
def test_edgelist(): | def test_edgelist(): | ||||
@@ -59,7 +59,7 @@ def test_edgelist(): | |||||
assert (100, 200) in el | assert (100, 200) in el | ||||
def test_million_sites(): | |||||
def test_stress(): | |||||
""" Testing that making a graph of ten thousand qubits takes less than half a second""" | """ Testing that making a graph of ten thousand qubits takes less than half a second""" | ||||
g = GraphState() | g = GraphState() | ||||
t = time.clock() | t = time.clock() | ||||