From 775eea02bb6eee270d63bc77ef524fe43a20bfd7 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Fri, 29 Jul 2016 21:56:38 -0700 Subject: [PATCH] Add a couple more tests --- tests/config.py | 6 ------ tests/mercedes.py | 1 - tests/test_measurement.py | 13 ++++++++++++- 3 files changed, 12 insertions(+), 8 deletions(-) delete mode 100644 tests/config.py diff --git a/tests/config.py b/tests/config.py deleted file mode 100644 index fa259bd..0000000 --- a/tests/config.py +++ /dev/null @@ -1,6 +0,0 @@ -""" -Generic configuration for testing -""" - -REPEATS = 100 -DEPTH = 100 diff --git a/tests/mercedes.py b/tests/mercedes.py index 2bc421e..732dae8 100644 --- a/tests/mercedes.py +++ b/tests/mercedes.py @@ -42,7 +42,6 @@ def test_single_qubit_measurements(): # Test something else assert g.measure_y(0, force=0) == 0 - def test_is_determinate(): """ Test whether asking if an outcome was random or determinate works """ g = GraphState([0]) diff --git a/tests/test_measurement.py b/tests/test_measurement.py index 33eb00f..8f5e157 100644 --- a/tests/test_measurement.py +++ b/tests/test_measurement.py @@ -4,7 +4,7 @@ from abp import qi, clifford from anders_briegel import graphsim from tqdm import tqdm import random -from config import * +import itertools as it def test_single_qubit_measurements(): """ Various simple tests of measurements """ @@ -26,6 +26,17 @@ def test_single_qubit_measurements(): g.act_local_rotation(0, "pz") 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(): """ Testing random behaviour """ ones = 0