Explorar el Código

Test passing

master
Pete Shadbolt hace 7 años
padre
commit
86b471e72a
Se han modificado 11 ficheros con 25 adiciones y 24 borrados
  1. +0
    -0
      examples/visualization/stress.py
  2. +1
    -1
      setup.py
  3. +2
    -4
      tests/mock.py
  4. +4
    -4
      tests/test_against_anders_and_briegel.py
  5. +5
    -5
      tests/test_graphstate.py
  6. +2
    -1
      tests/test_json.py
  7. +1
    -1
      tests/test_measurement.py
  8. +3
    -2
      tests/test_mercedes.py
  9. +3
    -2
      tests/test_nx.py
  10. +2
    -2
      tests/test_qi.py
  11. +2
    -2
      tests/test_stabilizer.py

examples/visualization/stress_test.py → examples/visualization/stress.py Ver fichero


+ 1
- 1
setup.py Ver fichero

@@ -16,7 +16,7 @@ setup(
keywords = "quantum",
setup_requires = ["numpy"],
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},
include_package_data=True
)

+ 2
- 4
tests/mock.py Ver fichero

@@ -6,10 +6,8 @@ import numpy as np
import abp
from abp import GraphState, clifford, qi
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
clifford.use_old_cz()


+ 4
- 4
tests/test_against_anders_and_briegel.py Ver fichero

@@ -1,9 +1,9 @@
from abp import GraphState, CircuitModel, clifford
import numpy as np
from numpy import random
from tqdm import tqdm
import itertools as it
import mock
import pytest
mock = pytest.importorskip("mock")

REPEATS = 100
DEPTH = 100
@@ -38,7 +38,7 @@ def test_cz_table():

def test_cz_hadamard(n=10):
""" 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 = [(mock.random_pair(n), gate) if gate == "cz"
else (random.choice(list(range(n))), gate)
@@ -48,7 +48,7 @@ def test_cz_hadamard(n=10):

def test_all(n=10):
""" 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 = [(mock.random_pair(n), gate) if gate == "cz"
else (random.choice(list(range(n))), gate)


+ 5
- 5
tests/test_graphstate.py Ver fichero

@@ -1,9 +1,9 @@
from abp import GraphState, CircuitModel, clifford
import mock
import random
import numpy as np
from tqdm import tqdm
import networkx as nx
import pytest
mock = pytest.importorskip("mock")

REPEATS = 100
DEPTH = 100
@@ -105,7 +105,7 @@ def test_local_complementation():

def test_single_qubit():
""" 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)]
a = mock.circuit_to_state(mock.ABPWrapper, 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):
""" 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)
a = mock.circuit_to_state(mock.ABPWrapper, 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):
""" 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)
a = mock.circuit_to_state(mock.ABPWrapper, n, circuit)
b = mock.circuit_to_state(mock.CircuitModelWrapper, n, circuit)


+ 2
- 1
tests/test_json.py Ver fichero

@@ -1,5 +1,6 @@
import mock
import abp
import pytest
mock = pytest.importorskip("mock")

def test_json():
""" Test to_json and from_json """


+ 1
- 1
tests/test_measurement.py Ver fichero

@@ -1,7 +1,7 @@
import numpy as np
from abp import GraphState
from abp import qi, clifford
from tqdm import tqdm
import random
import itertools as it



+ 3
- 2
tests/test_mercedes.py Ver fichero

@@ -1,6 +1,7 @@
from abp import GraphState
from abp.util import xyz
from mock import simple_graph
import pytest
mock = pytest.importorskip("mock")

def linear_cluster(n):
g = GraphState(list(range(n)), vop="hadamard")
@@ -51,7 +52,7 @@ def test_is_determinate():

def test_copy():
""" Make a copy of a graph """
a = simple_graph()
a = mock.simple_graph()
b = a.copy()
assert a == b


+ 3
- 2
tests/test_nx.py Ver fichero

@@ -3,12 +3,13 @@ import networkx as nx
from abp import GraphState, NXGraphState
from abp import clifford
from abp.util import xyz
from mock import simple_graph
import pytest
mock = pytest.importorskip("mock")


def test_json_basic():
""" Test that we can export to JSON """
g = simple_graph()
g = mock.simple_graph()
js = g.to_json()
assert "adj" in js
assert "node" in js


+ 2
- 2
tests/test_qi.py Ver fichero

@@ -1,7 +1,7 @@
import numpy as np
from abp import qi, GraphState
from tqdm import tqdm
import mock
import pytest
mock = pytest.importorskip("mock")

DEPTH = 1000



+ 2
- 2
tests/test_stabilizer.py Ver fichero

@@ -1,6 +1,6 @@
from abp import GraphState
from tqdm import tqdm
import mock
import pytest
mock = pytest.importorskip("mock")

REPEATS = 1000



Cargando…
Cancelar
Guardar