Browse Source

Add a couple more tests

master
Pete Shadbolt 8 years ago
parent
commit
775eea02bb
3 changed files with 12 additions and 8 deletions
  1. +0
    -6
      tests/config.py
  2. +0
    -1
      tests/mercedes.py
  3. +12
    -1
      tests/test_measurement.py

+ 0
- 6
tests/config.py View File

@@ -1,6 +0,0 @@
"""
Generic configuration for testing
"""

REPEATS = 100
DEPTH = 100

+ 0
- 1
tests/mercedes.py View File

@@ -42,7 +42,6 @@ def test_single_qubit_measurements():
# Test something else # Test something else
assert g.measure_y(0, force=0) == 0 assert g.measure_y(0, force=0) == 0



def test_is_determinate(): def test_is_determinate():
""" Test whether asking if an outcome was random or determinate works """ """ Test whether asking if an outcome was random or determinate works """
g = GraphState([0]) g = GraphState([0])


+ 12
- 1
tests/test_measurement.py View File

@@ -4,7 +4,7 @@ from abp import qi, clifford
from anders_briegel import graphsim from anders_briegel import graphsim
from tqdm import tqdm from tqdm import tqdm
import random import random
from config import *
import itertools as it


def test_single_qubit_measurements(): def test_single_qubit_measurements():
""" Various simple tests of measurements """ """ Various simple tests of measurements """
@@ -26,6 +26,17 @@ def test_single_qubit_measurements():
g.act_local_rotation(0, "pz") g.act_local_rotation(0, "pz")
assert g.measure(0, "px") == 1, "Measuring |-> in X gives 1" assert g.measure(0, "px") == 1, "Measuring |-> in X gives 1"


def test_type():
""" Test that the output is always an int """
for r, m, f in it.product(range(24), ("px", "py", "pz"), (0, 1)):
g = GraphState([0])
g.act_local_rotation(0, r)
assert str(g.measure(0, m)) in "01"
assert str(g.measure(0, m, f)) in "01"
assert g.measure(0, m, f, detail=True)["determinate"] == True



def test_random_outcomes(): def test_random_outcomes():
""" Testing random behaviour """ """ Testing random behaviour """
ones = 0 ones = 0


Loading…
Cancel
Save