From 7bc9895af6459eb56dfaa213a83e5f076000488c Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Wed, 11 May 2016 12:14:02 +0100 Subject: [PATCH] Test passing against the circuit model We fail when running against Anders and Briegel simply because we use a different CZ table --- abp/clifford.py | 2 +- tests/test_against_circuit_model.py | 9 +++++---- tests/test_clifford.py | 8 -------- tests/test_cphase_against_anders.py | 9 --------- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/abp/clifford.py b/abp/clifford.py index ac4fae5..1ec65bd 100644 --- a/abp/clifford.py +++ b/abp/clifford.py @@ -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) diff --git a/tests/test_against_circuit_model.py b/tests/test_against_circuit_model.py index d8b1701..d2b1587 100644 --- a/tests/test_against_circuit_model.py +++ b/tests/test_against_circuit_model.py @@ -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) diff --git a/tests/test_clifford.py b/tests/test_clifford.py index 603a650..93a5ec0 100644 --- a/tests/test_clifford.py +++ b/tests/test_clifford.py @@ -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"] diff --git a/tests/test_cphase_against_anders.py b/tests/test_cphase_against_anders.py index 244baa2..6b6cc79 100644 --- a/tests/test_cphase_against_anders.py +++ b/tests/test_cphase_against_anders.py @@ -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) - -