| @@ -16,7 +16,7 @@ setup( | |||||
| keywords = "quantum", | keywords = "quantum", | ||||
| setup_requires = ["numpy"], | setup_requires = ["numpy"], | ||||
| scripts = ["bin/abpserver"], | scripts = ["bin/abpserver"], | ||||
| install_requires = ["numpy", "networkx", "tqdm", "websocket-client", "websocket-server"], | |||||
| install_requires = ["numpy", "networkx", "websocket-client", "websocket-server"], | |||||
| package_data = {"abp.static": STATIC}, | package_data = {"abp.static": STATIC}, | ||||
| include_package_data=True | include_package_data=True | ||||
| ) | ) | ||||
| @@ -6,10 +6,8 @@ import numpy as np | |||||
| import abp | import abp | ||||
| from abp import GraphState, clifford, qi | from abp import GraphState, clifford, qi | ||||
| from numpy import random | from numpy import random | ||||
| try: | |||||
| from anders_briegel import graphsim | |||||
| except ImportError: | |||||
| raise nose.SkipTest("Original C++ is not available, skipping test") | |||||
| import pytest | |||||
| from anders_briegel import graphsim | |||||
| # We always run with A&B's CZ table when we are testing | # We always run with A&B's CZ table when we are testing | ||||
| clifford.use_old_cz() | clifford.use_old_cz() | ||||
| @@ -1,9 +1,9 @@ | |||||
| from abp import GraphState, CircuitModel, clifford | from abp import GraphState, CircuitModel, clifford | ||||
| import numpy as np | import numpy as np | ||||
| from numpy import random | from numpy import random | ||||
| from tqdm import tqdm | |||||
| import itertools as it | import itertools as it | ||||
| import mock | |||||
| import pytest | |||||
| mock = pytest.importorskip("mock") | |||||
| REPEATS = 100 | REPEATS = 100 | ||||
| DEPTH = 100 | DEPTH = 100 | ||||
| @@ -38,7 +38,7 @@ def test_cz_table(): | |||||
| def test_cz_hadamard(n=10): | def test_cz_hadamard(n=10): | ||||
| """ Test CZs and Hadamards at random """ | """ Test CZs and Hadamards at random """ | ||||
| for i in tqdm(list(range(REPEATS)), desc="Testing CZ and Hadamard against A&B"): | |||||
| for i in list(range(REPEATS)): | |||||
| circuit = random.choice(["cz", "hadamard"], DEPTH) | circuit = random.choice(["cz", "hadamard"], DEPTH) | ||||
| circuit = [(mock.random_pair(n), gate) if gate == "cz" | circuit = [(mock.random_pair(n), gate) if gate == "cz" | ||||
| else (random.choice(list(range(n))), gate) | else (random.choice(list(range(n))), gate) | ||||
| @@ -48,7 +48,7 @@ def test_cz_hadamard(n=10): | |||||
| def test_all(n=10): | def test_all(n=10): | ||||
| """ Test everything """ | """ Test everything """ | ||||
| for i in tqdm(list(range(REPEATS)), desc="Testing CZ and Hadamard against A&B"): | |||||
| for i in list(range(REPEATS)): | |||||
| circuit = random.choice(["cz"] * 10 + list(range(24)), DEPTH) | circuit = random.choice(["cz"] * 10 + list(range(24)), DEPTH) | ||||
| circuit = [(mock.random_pair(n), gate) if gate == "cz" | circuit = [(mock.random_pair(n), gate) if gate == "cz" | ||||
| else (random.choice(list(range(n))), gate) | else (random.choice(list(range(n))), gate) | ||||
| @@ -1,9 +1,9 @@ | |||||
| from abp import GraphState, CircuitModel, clifford | from abp import GraphState, CircuitModel, clifford | ||||
| import mock | |||||
| import random | import random | ||||
| import numpy as np | import numpy as np | ||||
| from tqdm import tqdm | |||||
| import networkx as nx | import networkx as nx | ||||
| import pytest | |||||
| mock = pytest.importorskip("mock") | |||||
| REPEATS = 100 | REPEATS = 100 | ||||
| DEPTH = 100 | DEPTH = 100 | ||||
| @@ -105,7 +105,7 @@ def test_local_complementation(): | |||||
| def test_single_qubit(): | def test_single_qubit(): | ||||
| """ A multi qubit test with Hadamards only""" | """ A multi qubit test with Hadamards only""" | ||||
| for repeat in tqdm(list(range(REPEATS)), desc="Single qubit rotations against CircuitModel"): | |||||
| for repeat in list(range(REPEATS)): | |||||
| circuit = [(0, random.choice(list(range(24)))) for i in range(DEPTH)] | circuit = [(0, random.choice(list(range(24)))) for i in range(DEPTH)] | ||||
| a = mock.circuit_to_state(mock.ABPWrapper, 1, circuit) | a = mock.circuit_to_state(mock.ABPWrapper, 1, circuit) | ||||
| b = mock.circuit_to_state(mock.CircuitModelWrapper, 1, circuit) | b = mock.circuit_to_state(mock.CircuitModelWrapper, 1, circuit) | ||||
| @@ -114,7 +114,7 @@ def test_single_qubit(): | |||||
| def test_graph_state_multiqubit(n=6): | def test_graph_state_multiqubit(n=6): | ||||
| """ A multi qubit test with Hadamards only""" | """ A multi qubit test with Hadamards only""" | ||||
| for repeat in tqdm(list(range(REPEATS)), desc="Random graph states against the CircuitModel"): | |||||
| for repeat in list(range(REPEATS)): | |||||
| circuit = mock.random_graph_circuit(n) | circuit = mock.random_graph_circuit(n) | ||||
| a = mock.circuit_to_state(mock.ABPWrapper, n, circuit) | a = mock.circuit_to_state(mock.ABPWrapper, n, circuit) | ||||
| b = mock.circuit_to_state(mock.CircuitModelWrapper, n, circuit) | b = mock.circuit_to_state(mock.CircuitModelWrapper, n, circuit) | ||||
| @@ -123,7 +123,7 @@ def test_graph_state_multiqubit(n=6): | |||||
| def test_stabilizer_state_multiqubit(n=6): | def test_stabilizer_state_multiqubit(n=6): | ||||
| """ A multi qubit test with arbitrary local rotations """ | """ A multi qubit test with arbitrary local rotations """ | ||||
| for repeat in tqdm(list(range(REPEATS)), desc="Random Clifford circuits against the CircuitModel"): | |||||
| for repeat in list(range(REPEATS)): | |||||
| circuit = mock.random_stabilizer_circuit(n) | circuit = mock.random_stabilizer_circuit(n) | ||||
| a = mock.circuit_to_state(mock.ABPWrapper, n, circuit) | a = mock.circuit_to_state(mock.ABPWrapper, n, circuit) | ||||
| b = mock.circuit_to_state(mock.CircuitModelWrapper, n, circuit) | b = mock.circuit_to_state(mock.CircuitModelWrapper, n, circuit) | ||||
| @@ -1,5 +1,6 @@ | |||||
| import mock | |||||
| import abp | import abp | ||||
| import pytest | |||||
| mock = pytest.importorskip("mock") | |||||
| def test_json(): | def test_json(): | ||||
| """ Test to_json and from_json """ | """ Test to_json and from_json """ | ||||
| @@ -1,7 +1,7 @@ | |||||
| import numpy as np | import numpy as np | ||||
| from abp import GraphState | from abp import GraphState | ||||
| from abp import qi, clifford | from abp import qi, clifford | ||||
| from tqdm import tqdm | |||||
| import random | import random | ||||
| import itertools as it | import itertools as it | ||||
| @@ -1,6 +1,7 @@ | |||||
| from abp import GraphState | from abp import GraphState | ||||
| from abp.util import xyz | from abp.util import xyz | ||||
| from mock import simple_graph | |||||
| import pytest | |||||
| mock = pytest.importorskip("mock") | |||||
| def linear_cluster(n): | def linear_cluster(n): | ||||
| g = GraphState(list(range(n)), vop="hadamard") | g = GraphState(list(range(n)), vop="hadamard") | ||||
| @@ -51,7 +52,7 @@ def test_is_determinate(): | |||||
| def test_copy(): | def test_copy(): | ||||
| """ Make a copy of a graph """ | """ Make a copy of a graph """ | ||||
| a = simple_graph() | |||||
| a = mock.simple_graph() | |||||
| b = a.copy() | b = a.copy() | ||||
| assert a == b | assert a == b | ||||
| @@ -3,12 +3,13 @@ import networkx as nx | |||||
| from abp import GraphState, NXGraphState | from abp import GraphState, NXGraphState | ||||
| from abp import clifford | from abp import clifford | ||||
| from abp.util import xyz | from abp.util import xyz | ||||
| from mock import simple_graph | |||||
| import pytest | |||||
| mock = pytest.importorskip("mock") | |||||
| def test_json_basic(): | def test_json_basic(): | ||||
| """ Test that we can export to JSON """ | """ Test that we can export to JSON """ | ||||
| g = simple_graph() | |||||
| g = mock.simple_graph() | |||||
| js = g.to_json() | js = g.to_json() | ||||
| assert "adj" in js | assert "adj" in js | ||||
| assert "node" in js | assert "node" in js | ||||
| @@ -1,7 +1,7 @@ | |||||
| import numpy as np | import numpy as np | ||||
| from abp import qi, GraphState | from abp import qi, GraphState | ||||
| from tqdm import tqdm | |||||
| import mock | |||||
| import pytest | |||||
| mock = pytest.importorskip("mock") | |||||
| DEPTH = 1000 | DEPTH = 1000 | ||||
| @@ -1,6 +1,6 @@ | |||||
| from abp import GraphState | from abp import GraphState | ||||
| from tqdm import tqdm | |||||
| import mock | |||||
| import pytest | |||||
| mock = pytest.importorskip("mock") | |||||
| REPEATS = 1000 | REPEATS = 1000 | ||||