Browse Source

Test passing against the circuit model

We fail when running against Anders and Briegel simply because we use a
different CZ table
master
Pete Shadbolt 8 years ago
parent
commit
7bc9895af6
4 changed files with 6 additions and 22 deletions
  1. +1
    -1
      abp/clifford.py
  2. +5
    -4
      tests/test_against_circuit_model.py
  3. +0
    -8
      tests/test_clifford.py
  4. +0
    -9
      tests/test_cphase_against_anders.py

+ 1
- 1
abp/clifford.py View File

@@ -153,7 +153,7 @@ except IOError:
conjugation_table = get_conjugation_table(unitaries)
times_table = get_times_table(unitaries)
cz_table = get_cz_table(unitaries)
cz_table = get_ab_cz_table()
#cz_table = get_ab_cz_table()

# Write it all to disk
np.save("unitaries.npy", unitaries)


+ 5
- 4
tests/test_against_circuit_model.py View File

@@ -3,12 +3,13 @@ from abp.qi import CircuitModel
from abp import clifford
import numpy as np
import random
from tqdm import tqdm

REPEATS = 10
REPEATS = 100

def test_single_qubit(n=1):
""" A multi qubit test with Hadamards only"""
for repeat in range(REPEATS):
for repeat in tqdm(range(REPEATS), desc="Testing against circuit model") :
g = GraphState([0])
c = CircuitModel(1)

@@ -22,7 +23,7 @@ def test_single_qubit(n=1):

def test_hadamard_only_multiqubit(n=6):
""" A multi qubit test with Hadamards only"""
for qqq in range(REPEATS):
for repeat in tqdm(range(REPEATS), desc="Testing against circuit model") :
g = GraphState(range(n))
c = CircuitModel(n)

@@ -53,7 +54,7 @@ def test_all_multiqubit(n=4):

assert g.to_state_vector() == c

for i in range(100):
for repeat in tqdm(range(REPEATS), desc="Testing against circuit model") :
a, b = np.random.randint(0, n-1, 2)
if a != b:
g.act_cz(a, b)


+ 0
- 8
tests/test_clifford.py View File

@@ -67,14 +67,6 @@ def test_times_table():
assert clifford.times_table[0][4] == 4


def _test_cz_table_is_symmetric():
""" Test the CZ table is symmetric """
for bond, (a, b) in it.product([0, 1], it.combinations(xrange(24), 2)):
_, a1, a2 = clifford.cz_table[bond, a, b]
_, b1, b2 = clifford.cz_table[bond, b, a]
assert (a1, a2) == (b2, b1)


def test_cz_table_makes_sense():
""" Test the CZ table is symmetric """
hadamard = clifford.by_name["hadamard"]


+ 0
- 9
tests/test_cphase_against_anders.py View File

@@ -39,12 +39,3 @@ def test_cz_table():
assert np.allclose(computed_output, table_output)


def _test_match():
""" Tests that they actually match """
ab_cz_table = get_ab_cz_table()

rows = it.product([0, 1], it.combinations_with_replacement(range(24), 2))
for bond, (c1, c2) in rows:
assert np.all(ab_cz_table == clifford.cz_table)



Loading…
Cancel
Save