From 56e65b6c7fbc0e42f0e6de3cc2909beddb1e4e06 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Tue, 20 Dec 2016 23:03:48 -0800 Subject: [PATCH 1/8] Reverse order of tuples in GraphState.act_circuit Seems vaguely sensible. Haven't tested because I'm on a plane. --- abp/graphstate.py | 6 +++--- doc/index.rst | 4 ++-- tests/mock.py | 10 +++++----- tests/test_graphstate.py | 4 ++-- tests/test_mercedes.py | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/abp/graphstate.py b/abp/graphstate.py index 25d1b09..6ef23d4 100755 --- a/abp/graphstate.py +++ b/abp/graphstate.py @@ -99,14 +99,14 @@ class GraphState(object): def act_circuit(self, circuit): """ Run many gates in one call. - :param circuit: An iterable containing tuples of the form ``(node, operation)``. If ``operation`` is a name for a local operation (e.g. ``6``, ``hadamard``) then that operation is performed on ``node``. If ``operation`` is ``cz`` then a CZ is performed on the two nodes in ``node``. + :param circuit: An iterable containing tuples of the form ``(operation, node)``. If ``operation`` is a name for a local operation (e.g. ``6``, ``hadamard``) then that operation is performed on ``node``. If ``operation`` is ``cz`` then a CZ is performed on the two nodes in ``node``. Example (makes a Bell pair):: - >>> g.act_circuit([(0, "hadamard"), (1, "hadamard"), ((0, 1), "cz")]) + >>> g.act_circuit([("hadamard", 0), ("hadamard", 1), ("cz", (0, 1))]) """ - for node, operation in circuit: + for operation, node in circuit: if operation == "cz": self.act_cz(*node) else: diff --git a/doc/index.rst b/doc/index.rst index b0ef553..4e3bfb2 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -166,8 +166,8 @@ This ought to pop open a browser window at ``http://localhost:5001/``. You can r >>> from abp import GraphState, VizClient >>> g = GraphState(10) - >>> g.act_circuit([(i, "hadamard") for i in range(10)]) - >>> g.act_circuit([((i, i+1), "cz") for i in range(9)]) + >>> g.act_circuit([("hadamard", i) for i in range(10)]) + >>> g.act_circuit([("cz", (i, i+1)) for i in range(9)]) >>> v = VizClient() >>> v.update(g) diff --git a/tests/mock.py b/tests/mock.py index 547edc4..642040c 100644 --- a/tests/mock.py +++ b/tests/mock.py @@ -42,7 +42,7 @@ class AndersWrapper(graphsim.GraphRegister): return self.to_json() == other.to_json() def act_circuit(self, circuit): - for node, operation in circuit: + for operation, node in circuit: if operation == "cz": self.act_cz(*node) else: @@ -106,8 +106,8 @@ def named_node_graph(): """ A graph with named nodes""" edges = (0, 1), (1, 2), (2, 0), (0, 3), (100, 200), (200, "named") g = ABPWrapper([0, 1, 2, 3, 100, 200, "named"]) - g.act_circuit((i, "hadamard") for i in g.node) - g.act_circuit((edge, "cz") for edge in edges) + g.act_circuit(("hadamard", i) for i in g.node) + g.act_circuit(("cz", edge) for edge in edges) return g @@ -115,8 +115,8 @@ def simple_graph(): """ A simple graph to test with""" edges = (0, 1), (1, 2), (2, 0), (0, 3), (100, 200) g = ABPWrapper([0, 1, 2, 3, 100, 200]) - g.act_circuit((i, "hadamard") for i in g.node) - g.act_circuit((edge, "cz") for edge in edges) + g.act_circuit(("hadamard", i) for i in g.node) + g.act_circuit(("cz", edge) for edge in edges) return g diff --git a/tests/test_graphstate.py b/tests/test_graphstate.py index 9689321..f307d70 100644 --- a/tests/test_graphstate.py +++ b/tests/test_graphstate.py @@ -94,8 +94,8 @@ def test_local_complementation(): """ Test that local complementation works okay """ pairs = (0, 1), (0, 3), (1, 3), (1, 2), psi = GraphState(range(4), vop="hadamard") - psi.act_circuit([(i, "hadamard") for i in psi.node]) - psi.act_circuit([(pair, "cz") for pair in pairs]) + psi.act_circuit([("hadamard", i) for i in psi.node]) + psi.act_circuit([("cz", pair) for pair in pairs]) old_edges = psi.edgelist() old_state = psi.to_state_vector() psi.local_complementation(1) diff --git a/tests/test_mercedes.py b/tests/test_mercedes.py index 3a4e81b..548193e 100644 --- a/tests/test_mercedes.py +++ b/tests/test_mercedes.py @@ -4,8 +4,8 @@ from mock import simple_graph def linear_cluster(n): g = GraphState(range(n), vop="hadamard") - g.act_circuit([(i, "hadamard") for i in range(n)]) - g.act_circuit([((i, i+1), "cz") for i in range(n-1)]) + g.act_circuit([("hadamard", i) for i in range(n)]) + g.act_circuit([("cz", (i, i+1)) for i in range(n-1)]) return g From 75e6b73e71bbb52eb063c56fbd628e00ba380139 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Tue, 20 Dec 2016 23:06:13 -0800 Subject: [PATCH 2/8] =?UTF-8?q?Bump=20version:=200.4.24=20=E2=86=92=200.4.?= =?UTF-8?q?25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- README.md | 4 ++-- abp/static/index.html | 2 +- abp/static/scripts/main.js | 2 +- bin/abpserver | 2 +- doc/conf.py | 4 ++-- doc/index.rst | 2 +- setup.py | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index b38ebd2..7e586fc 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.4.24 +current_version = 0.4.25 commit = True tag = True diff --git a/README.md b/README.md index cd989c8..05d4e73 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# abp 0.4.24 +# abp 0.4.25 Python port of Anders and Briegel' s [method](https://arxiv.org/abs/quant-ph/0504117) for fast simulation of Clifford circuits. ## Documentation @@ -8,7 +8,7 @@ You can read the full documentation [here](https://peteshadbolt.co.uk/abp/). You It's easiest to install with `pip`: ```shell -$ pip install --user abp==0.4.24 +$ pip install --user abp==0.4.25 ``` Or clone and install in `develop` mode: diff --git a/abp/static/index.html b/abp/static/index.html index efcf780..c2c5f88 100644 --- a/abp/static/index.html +++ b/abp/static/index.html @@ -24,7 +24,7 @@ -
Version 0.4.24
+
Version 0.4.25