|
|
@@ -4,12 +4,16 @@ |
|
|
|
This module implements Anders and Briegel's method for fast simulation of Clifford circuits. |
|
|
|
""" |
|
|
|
|
|
|
|
from __future__ import absolute_import |
|
|
|
from __future__ import print_function |
|
|
|
import itertools as it |
|
|
|
import json, random |
|
|
|
from . import qi, clifford, util |
|
|
|
import abp |
|
|
|
from .stabilizer import Stabilizer |
|
|
|
import requests |
|
|
|
from six.moves import range |
|
|
|
from six.moves import zip |
|
|
|
|
|
|
|
|
|
|
|
class GraphState(object): |
|
|
@@ -63,12 +67,12 @@ class GraphState(object): |
|
|
|
self._del_node(node) |
|
|
|
|
|
|
|
def _add_node(self, node, **kwargs): |
|
|
|
""" Add a node. |
|
|
|
""" Add a node. |
|
|
|
|
|
|
|
By default, nodes are initialized with ``vop=``:math:`I`, i.e. they are in the :math:`|+\\rangle` state. |
|
|
|
""" |
|
|
|
if node in self.node: |
|
|
|
print("Warning: node {} already exists".format(node)) |
|
|
|
print(("Warning: node {} already exists".format(node))) |
|
|
|
return |
|
|
|
|
|
|
|
default = kwargs.get("default", "identity") |
|
|
@@ -91,7 +95,7 @@ class GraphState(object): |
|
|
|
|
|
|
|
>>> g._add_node(0, label="fred", position=(1,2,3)) |
|
|
|
>>> g.node[0]["label"] |
|
|
|
fred |
|
|
|
fred |
|
|
|
|
|
|
|
""" |
|
|
|
kwargs["vop"] = clifford.by_name[ |
|
|
@@ -500,17 +504,17 @@ class GraphState(object): |
|
|
|
self.url = requests.get("https://abv.peteshadbolt.co.uk/").url |
|
|
|
|
|
|
|
data = json.dumps(self.to_json(stringify=True)) |
|
|
|
print("Shared state to {}".format(self.url)) |
|
|
|
print(("Shared state to {}".format(self.url))) |
|
|
|
return requests.post("{}/graph".format(self.url), data=data) |
|
|
|
|
|
|
|
def pull(self, url=None): |
|
|
|
""" Loads the state from the server """ |
|
|
|
if url: |
|
|
|
if url: |
|
|
|
self.url = url |
|
|
|
|
|
|
|
response = requests.get("{}/graph".format(self.url)) |
|
|
|
self.from_json(json.loads(response.content)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|