Sfoglia il codice sorgente

Add a couple more tests

master
Pete Shadbolt 8 anni fa
parent
commit
775eea02bb
3 ha cambiato i file con 12 aggiunte e 8 eliminazioni
  1. +0
    -6
      tests/config.py
  2. +0
    -1
      tests/mercedes.py
  3. +12
    -1
      tests/test_measurement.py

+ 0
- 6
tests/config.py Vedi File

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

REPEATS = 100
DEPTH = 100

+ 0
- 1
tests/mercedes.py Vedi File

@@ -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])


+ 12
- 1
tests/test_measurement.py Vedi File

@@ -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


Loading…
Annulla
Salva