Browse Source

Not much

master
Pete Shadbolt 5 years ago
parent
commit
261c3a1c0f
3 changed files with 13 additions and 14 deletions
  1. +7
    -1
      abp/graphstate.py
  2. +0
    -8
      examples/visualization/pull.py
  3. +6
    -5
      examples/visualization/raussendorf.py

+ 7
- 1
abp/graphstate.py View File

@@ -12,6 +12,7 @@ from . import qi, clifford, util
import abp import abp
from .stabilizer import Stabilizer from .stabilizer import Stabilizer
import requests import requests
import numpy as np
from six.moves import range from six.moves import range
from six.moves import zip from six.moves import zip


@@ -504,7 +505,12 @@ class GraphState(object):
if self.url == None: if self.url == None:
self.url = requests.get("https://abv.peteshadbolt.co.uk/").url self.url = requests.get("https://abv.peteshadbolt.co.uk/").url


data = json.dumps(self.to_json(stringify=True))
def default(o):
if isinstance(o, np.int64):
return int(o)
raise TypeError

data = json.dumps(self.to_json(stringify=True), default=default)
print(("Shared state to {}".format(self.url))) print(("Shared state to {}".format(self.url)))
return requests.post("{}/graph".format(self.url), data=data) return requests.post("{}/graph".format(self.url), data=data)




+ 0
- 8
examples/visualization/pull.py View File

@@ -1,8 +0,0 @@
from __future__ import absolute_import
from __future__ import print_function
from abp import GraphState

psi = GraphState()
psi.pull("https://abv.peteshadbolt.co.uk/dakota-illinois-nuts-blue")
print(psi)


+ 6
- 5
examples/visualization/raussendorf.py View File

@@ -19,7 +19,7 @@ raussendorf_unit_cell = (
((2, 1, 0), (2, 1, 1)), ((2, 0, 1), (2, 1, 1)), ((2, 1, 0), (2, 1, 1)), ((2, 0, 1), (2, 1, 1)),
((2, 1, 2), (2, 1, 1)), ((2, 2, 1), (2, 1, 1)), ((2, 1, 2), (2, 1, 1)), ((2, 2, 1), (2, 1, 1)),
((1, 0, 0), (1, 0, 1)), ((0, 0, 1), (1, 0, 1)), ((1, 0, 0), (1, 0, 1)), ((0, 0, 1), (1, 0, 1)),
((1, 0, 2), (1, 0, 1)), ((2, 0, 1), (1, 0, 1)),
((1, 0, 2), (1, 0, 1)), ((2, 0, 1), (1, 0, 1)),
((1, 2, 0), (1, 2, 1)), ((0, 2, 1), (1, 2, 1)), ((1, 2, 0), (1, 2, 1)), ((0, 2, 1), (1, 2, 1)),
((1, 2, 2), (1, 2, 1)), ((2, 2, 1), (1, 2, 1))) ((1, 2, 2), (1, 2, 1)), ((2, 2, 1), (1, 2, 1)))


@@ -31,7 +31,8 @@ def add_offset(vector, offset):


def offset_unit_cell(unit_cell, offset): def offset_unit_cell(unit_cell, offset):
""" Offset a unit cell """ """ Offset a unit cell """
return {(add_offset(a, offset), add_offset(b, offset)) for a, b in unit_cell}
return {(add_offset(a, offset), add_offset(b, offset))
for a, b in unit_cell}




def lattice(unit_cell, size): def lattice(unit_cell, size):
@@ -43,12 +44,13 @@ def lattice(unit_cell, size):
nodes = set(itertools.chain(*edges)) nodes = set(itertools.chain(*edges))
return nodes, edges return nodes, edges


nodes, edges = lattice(raussendorf_unit_cell, (2, 2, 3 ))

nodes, edges = lattice(raussendorf_unit_cell, (2, 2, 3))


psi = GraphState() psi = GraphState()
for node in nodes: for node in nodes:
x, y, z = node x, y, z = node
color = "red" if (x+y+z) % 2 > 0 else "black"
color = "red" if (x+y+z) % 2 > 0 else "black"
psi.add_qubit(node, position=xyz(*node), color=color) psi.add_qubit(node, position=xyz(*node), color=color)
psi.act_hadamard(node) psi.act_hadamard(node)


@@ -56,4 +58,3 @@ for edge in edges:
psi.act_cz(edge[0], edge[1]) psi.act_cz(edge[0], edge[1])


psi.push() psi.push()


Loading…
Cancel
Save