From 82ede1f24bc0b18e6afb61bf2305b4a9e67d0949 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Sun, 28 Feb 2016 15:07:27 +0000 Subject: [PATCH] Testing that we really are in a group --- tests/test_clifford.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_clifford.py b/tests/test_clifford.py index 374160d..ad4e43d 100644 --- a/tests/test_clifford.py +++ b/tests/test_clifford.py @@ -59,3 +59,16 @@ def test_we_have_all_useful_gates(): assert any(x > 0 for x in results) phase, index = [(i, r) for i, r in enumerate(results) if r>=0][0] print "exp(1j*{}*pi/4) . {}\t=\tlc.unitaries[{}]".format(phase, name, index) + + +def test_group(): + """ Test we are really in a group """ + for a in lc.unitaries: + for b in lc.unitaries: + unitary = a*b + rotated = [exp(1j * phase * pi / 4.) * unitary for phase in range(8)] + results = [find_u(r, lc.unitaries) for r in rotated] + assert len([x for x in results if x>=0])==1 + + +