From 61079462447749a8967f11278363345ad15e05ca Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Mon, 25 Jul 2016 07:09:58 +0100 Subject: [PATCH] Pratting with MANIFEST --- MANIFEST.in | 1 + examples/local_complementation.py | 20 ------ examples/mix_graph_and_networkx.py | 9 ++- remake.sh | 8 +++ run.sh | 8 +++ setup.py | 12 ++-- tests/graphs/.gitignore | 1 - tests/graphs/graph2.g6 | 2 - tests/graphs/graph3.g6 | 4 -- tests/graphs/graph4.g6 | 11 --- tests/graphs/graph5.g6 | 34 ---------- ..._measurement_against_anders_and_briegel.py | 67 ------------------- ...st_single_qubit_measurement_against_anb.py | 23 ------- 13 files changed, 30 insertions(+), 170 deletions(-) create mode 100644 MANIFEST.in delete mode 100644 examples/local_complementation.py create mode 100644 remake.sh create mode 100755 run.sh delete mode 100644 tests/graphs/.gitignore delete mode 100644 tests/graphs/graph2.g6 delete mode 100644 tests/graphs/graph3.g6 delete mode 100644 tests/graphs/graph4.g6 delete mode 100644 tests/graphs/graph5.g6 delete mode 100644 tests/old/test_measurement_against_anders_and_briegel.py delete mode 100644 tests/old/test_single_qubit_measurement_against_anb.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..37ac3d1 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include abp/static * diff --git a/examples/local_complementation.py b/examples/local_complementation.py deleted file mode 100644 index 3458eb0..0000000 --- a/examples/local_complementation.py +++ /dev/null @@ -1,20 +0,0 @@ -from abp.fancy import GraphState -from abp.util import xyz -from abp.clifford import * - -psi = GraphState() -psi.add_node(0, position = xyz(0, 0)) -psi.add_node(1, position = xyz(1, 1)) -psi.add_node(2, position = xyz(3, 2)) -psi.add_node(3, position = xyz(0, 3)) - -for n in psi.node: - psi.act_hadamard(n) - -psi.act_cz(0, 1) -psi.act_cz(0, 3) -psi.act_cz(1, 3) -psi.act_cz(1, 2) -while True: - psi.update() - psi.local_complementation(1) diff --git a/examples/mix_graph_and_networkx.py b/examples/mix_graph_and_networkx.py index f4a33ac..c89af56 100644 --- a/examples/mix_graph_and_networkx.py +++ b/examples/mix_graph_and_networkx.py @@ -1,6 +1,9 @@ from abp.fancy import GraphState +from abp.util import xyz +import networkx as nx -g = GraphState() -n = 100 -g.add_nodes_from(range(n)) +n = 10 +g = GraphState(range(n)) +nx.set_node_attributes(g, "color", "red") g.add_edges_from([i, i+1] for i in range(n-1)) +print g.node[0]["color"] diff --git a/remake.sh b/remake.sh new file mode 100644 index 0000000..e8094af --- /dev/null +++ b/remake.sh @@ -0,0 +1,8 @@ +#!/bin/bash +rm -r abp.egg-info +rm -r build +rm -r dist + +python setup.py build sdist + +tar -tvf dist/abp-0.4.5.tar.gz diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..e8094af --- /dev/null +++ b/run.sh @@ -0,0 +1,8 @@ +#!/bin/bash +rm -r abp.egg-info +rm -r build +rm -r dist + +python setup.py build sdist + +tar -tvf dist/abp-0.4.5.tar.gz diff --git a/setup.py b/setup.py index 919a3ac..5e20892 100755 --- a/setup.py +++ b/setup.py @@ -1,13 +1,14 @@ -from setuptools import setup, find_packages +from setuptools import setup from glob import glob from os import path -STATIC = glob("static/*.*")+glob("static/img/*.*")+glob("static/scripts/*.*") +STATIC = glob("abp/static/*.*")+glob("abp/static/img/*.*")+glob("abp/static/scripts/*.*") +print STATIC setup( name = "abp", - version = "0.4.3", - packages = find_packages(), + version = "0.4.6", + packages = ["abp", "abp.static"], test_suite = "tests", author = "Pete Shadbolt", author_email = "hello@peteshadbolt.co.uk", @@ -17,5 +18,6 @@ setup( setup_requires = ["numpy"], scripts = ["bin/abpserver"], install_requires = ["numpy", "networkx", "tqdm", "websocket-client", "websocket-server"], - package_data = {"abp.static": STATIC} + package_data = {"abp.static": STATIC}, + include_package_data=True ) diff --git a/tests/graphs/.gitignore b/tests/graphs/.gitignore deleted file mode 100644 index 8a58ef6..0000000 --- a/tests/graphs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -graph9.g6 diff --git a/tests/graphs/graph2.g6 b/tests/graphs/graph2.g6 deleted file mode 100644 index 47c6bbe..0000000 --- a/tests/graphs/graph2.g6 +++ /dev/null @@ -1,2 +0,0 @@ -A? -A_ diff --git a/tests/graphs/graph3.g6 b/tests/graphs/graph3.g6 deleted file mode 100644 index b19caa6..0000000 --- a/tests/graphs/graph3.g6 +++ /dev/null @@ -1,4 +0,0 @@ -B? -BO -BW -Bw diff --git a/tests/graphs/graph4.g6 b/tests/graphs/graph4.g6 deleted file mode 100644 index 0c248ce..0000000 --- a/tests/graphs/graph4.g6 +++ /dev/null @@ -1,11 +0,0 @@ -C? -CC -CE -CF -CQ -CT -CU -CV -C] -C^ -C~ diff --git a/tests/graphs/graph5.g6 b/tests/graphs/graph5.g6 deleted file mode 100644 index 1771b06..0000000 --- a/tests/graphs/graph5.g6 +++ /dev/null @@ -1,34 +0,0 @@ -D?? -D?_ -D?o -D?w -D?{ -DCO -DCW -DCc -DCo -DCs -DCw -DC{ -DEk -DEo -DEs -DEw -DE{ -DFw -DF{ -DQg -DQo -DQw -DQ{ -DTk -DTw -DT{ -DUW -DUw -DU{ -DV{ -D]w -D]{ -D^{ -D~{ diff --git a/tests/old/test_measurement_against_anders_and_briegel.py b/tests/old/test_measurement_against_anders_and_briegel.py deleted file mode 100644 index 2e003ce..0000000 --- a/tests/old/test_measurement_against_anders_and_briegel.py +++ /dev/null @@ -1,67 +0,0 @@ -from abp import GraphState, clifford -from anders_briegel import graphsim -import numpy as np -from tqdm import tqdm -import dummy -import itertools as it -from config import * - -N = 10 - -m = {1: graphsim.lco_X, 2: graphsim.lco_Y, 3: graphsim.lco_Z} - -def test_2qubit(): - """ Relentless testing of measurements """ - clifford.use_old_cz() - for measurement in (3, 2, 1): - for outcome in (0, 1): - a, b = dummy.bell() - a.measure(0, str(measurement), outcome) - b.measure(0, m[measurement], None, outcome) - assert a == b, (measurement, outcome) - -def test_multiqubit(): - """ Relentless testing of measurements """ - for measurement in (3,2,1,): - for i in tqdm(range(REPEATS), "Testing measurement {}".format(measurement)): - for outcome in (0, 1): - a, b = dummy.clean_random_state(N) - a.measure(0, str(measurement), outcome) - b.measure(0, m[measurement], None, outcome) - assert a == b, (measurement, outcome) - -def test_multiqubit2(): - """ Relentless testing of measurements """ - for measurement in (3,2,1): - for i in tqdm(range(REPEATS), "Testing {} measurement".format(measurement)): - for outcome in (0, 1): - for rotation in range(24): - a, b = dummy.clean_random_state(N) - assert a == b - a.act_local_rotation(0, str(rotation)) - b.local_op(0, graphsim.LocCliffOp(rotation)) - - #print "{} ------------------".format(rotation) - #print "pjs b4:", a.to_json() - #print "a&b b4:", b.to_json() - oa = a.measure(0, str(measurement), outcome) - ob = b.measure(0, m[measurement], None, outcome) - assert oa == ob, (oa, ob, rotation) - #print "pjs af:", a.to_json() - #print "a&b af:", b.to_json() - assert a == b, (measurement, outcome, rotation) - #print - - -def test_multiqubit3(): - """ More measurement """ - for i in tqdm(range(REPEATS), "Testing messy measurement"): - for measurement, outcome in it.product((3,2,1), (0,1)): - a, b = dummy.messy_random_state(N) - assert a == b - oa = a.measure(0, str(measurement), outcome) - ob = b.measure(0, m[measurement], None, outcome) - assert oa == ob, (oa, ob, rotation) - assert a == b, (measurement, outcome) - - diff --git a/tests/old/test_single_qubit_measurement_against_anb.py b/tests/old/test_single_qubit_measurement_against_anb.py deleted file mode 100644 index 8dc846f..0000000 --- a/tests/old/test_single_qubit_measurement_against_anb.py +++ /dev/null @@ -1,23 +0,0 @@ -from abp import GraphState, clifford -from anders_briegel import graphsim -import numpy as np -from tqdm import tqdm -import itertools as it -import dummy -from config import * - -N = 10 -m = {1: graphsim.lco_X, 2: graphsim.lco_Y, 3: graphsim.lco_Z} - -def test_1(): - """ Check that single qubits work """ - space = it.product(range(24), (3,2,1), (0,1)) - for rotation, measurement, outcome in tqdm(space, "Testing single qubit measurements"): - #print "\nr{} m{} o{}".format(rotation, measurement, outcome) - a, b = dummy.onequbit() - #print a.to_json()["node"][0]["vop"], b.to_json()["node"][0]["vop"] - a.measure(0, str(measurement), outcome) - b.measure(0, m[measurement], None, outcome) - #print a.to_json()["node"][0]["vop"], b.to_json()["node"][0]["vop"] - assert a == b, (a.to_json()["node"][0], b.to_json()["node"][0]) -