From bbc89eb4dea262cce8b98d62764ecb924b426ecd Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Wed, 11 May 2016 01:51:02 +0100 Subject: [PATCH] Modify test --- abp/clifford.py | 2 +- tests/test_against_circuit_model.py | 44 ++++++++++++++--------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/abp/clifford.py b/abp/clifford.py index 9dc89e9..5ba5b0f 100644 --- a/abp/clifford.py +++ b/abp/clifford.py @@ -150,7 +150,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 80d6047..f953fcf 100644 --- a/tests/test_against_circuit_model.py +++ b/tests/test_against_circuit_model.py @@ -4,6 +4,7 @@ from abp import clifford import numpy as np import random + def test_hadamard_only_multiqubit(): """ A multi qubit test with Hadamards only""" n = 4 @@ -17,7 +18,7 @@ def test_hadamard_only_multiqubit(): assert g.to_state_vector() == c for i in range(100): - a, b = np.random.randint(0, n-1, 2) + a, b = np.random.randint(0, n - 1, 2) if a != b: g.act_cz(a, b) c.act_cz(a, b) @@ -25,26 +26,23 @@ def test_hadamard_only_multiqubit(): assert g.to_state_vector() == c -def test_all_multiqubit(): +def test_all_multiqubit(n=4): """ A multi qubit test with arbitrary local rotations """ - n = 4 - g = GraphState(range(n)) - c = CircuitModel(n) - - for i in range(10): - qubit = np.random.randint(0, n-1) - rotation = np.random.randint(0, 24-1) - g.act_local_rotation(qubit, rotation) - c.act_local_rotation(qubit, clifford.unitaries[rotation]) - - - assert g.to_state_vector() == c - - #for i in range(100): - #a, b = np.random.randint(0, n-1, 2) - #if a != b: - #g.act_cz(a, b) - #c.act_cz(a, b) - - assert g.to_state_vector() == c - + for j in range(100): + n = 4 + g = GraphState(range(n)) + c = CircuitModel(n) + for i in range(10): + qubit = np.random.randint(0, n - 1) + rotation = np.random.randint(0, 24 - 1) + g.act_local_rotation(qubit, rotation) + c.act_local_rotation(qubit, clifford.unitaries[rotation]) + assert g.to_state_vector() == c + + for i in range(1): + a, b = np.random.randint(0, n-1, 2) + if a != b: + g.act_cz(a, b) + c.act_cz(a, b) + + assert g.to_state_vector() == c