Browse Source

Very good! Tests pass :rage4: :gun:

Next up is just to clean those tests and replace the stupid
act_local_rotation2 with something legible.
master
Pete Shadbolt 7 years ago
parent
commit
140a9cd7ba
3 changed files with 27 additions and 11 deletions
  1. +10
    -6
      tests/dummy.py
  2. +0
    -2
      tests/nodetest1.js
  3. +17
    -3
      tests/test_measurement_against_anders_and_briegel.py

+ 10
- 6
tests/dummy.py View File

@@ -21,17 +21,21 @@ def clean_random_state(N=10):

def messy_random_state(N=10):
a, b = clean_random_state(N)
for i in range(10):
j = np.random.choice(range(N))
k = np.random.choice(range(24))
a.act_local_rotation(j, k)
b.local_op(j, graphsim.LocCliffOp(k))
for i in range(N):
a.act_hadamard(i)
b.hadamard(i)

for i in range(10):
for i in range(N):
j, k= np.random.choice(range(N), 2, replace=False)
a.act_cz(j, k)
b.cphase(j, k)

for i in range(N):
j = np.random.choice(range(N))
k = np.random.choice(range(24))
a.act_local_rotation(j, k)
b.local_op(j, graphsim.LocCliffOp(k))

return a, b

def bell():


+ 0
- 2
tests/nodetest1.js View File

@@ -1,2 +0,0 @@
eval(require('fs').readFileSync('../static/scripts/anders_briegel.js', 'utf8'));
console.log(abj.adj);

+ 17
- 3
tests/test_measurement_against_anders_and_briegel.py View File

@@ -3,9 +3,10 @@ from anders_briegel import graphsim
import numpy as np
from tqdm import tqdm
import dummy
import itertools as it

N = 10
REPEATS = 10
REPEATS = 1000
m = {1: graphsim.lco_X, 2: graphsim.lco_Y, 3: graphsim.lco_Z}

def test_2qubit():
@@ -30,11 +31,11 @@ def test_multiqubit():
def test_multiqubit2():
""" Relentless testing of measurements """
for measurement in (3,):
for measurement in (3,2,1):
for i in tqdm(range(REPEATS), "Testing {} measurement".format(measurement)):
for outcome in (0, 1):
for rotation in range(24):
a, b = dummy.clean_random_state(3)
a, b = dummy.clean_random_state(N)
assert a == b
a.act_local_rotation(0, str(rotation))
b.local_op(0, graphsim.LocCliffOp(rotation))
@@ -50,3 +51,16 @@ def test_multiqubit2():
assert a == b, (measurement, outcome, rotation)
#print

def test_multiqubit3():
""" More measurement """
for i in tqdm(range(REPEATS), "Testing messy measurement"):
for measurement, outcome in it.product((3,2,1), (0,1)):
a, b = dummy.messy_random_state(N)
assert a == b
oa = a.measure(0, str(measurement), outcome)
ob = b.measure(0, m[measurement], None, outcome)
assert oa == ob, (oa, ob, rotation)
assert a == b, (measurement, outcome)


Loading…
Cancel
Save