Parcourir la source

First attempt at fixing naming scheme

master
Pete Shadbolt il y a 8 ans
Parent
révision
a1eabb33ea
5 fichiers modifiés avec 41 ajouts et 8 suppressions
  1. +6
    -7
      abp/clifford.py
  2. +1
    -1
      abp/graphstate.py
  3. +19
    -0
      tests/test_against_anders_and_briegel.py
  4. +7
    -0
      tests/test_clifford_names.py
  5. +8
    -0
      tests/test_quantum.py

+ 6
- 7
abp/clifford.py Voir le fichier

@@ -17,12 +17,9 @@ decompositions = ("xxxx", "xx", "zzxx", "zz", "zxx", "z", "zzz", "xxz",
"xzx", "xzxxx", "xzzzx", "xxxzx", "xzz", "zzx", "xxx", "x",
"zzzx", "xxzx", "zx", "zxxx", "xxxz", "xzzz", "xz", "xzxx")

#{"UUUU", "UU", "VVUU", "VV",
#"VUU", "V", "VVV", "UUV",
#"UVU", "UVUUU", "UVVVU", "UUUVU",
#"UVV", "VVU", "UUU", "U",
#"VVVU", "UUVU", "VU", "VUUU",
#"UUUV", "UVVV", "UV", "UVUU"};
#{"UUUU", "UU", "VVUU", "VV", #"VUU", "V", "VVV", "UUV",
#"UVU", "UVUUU", "UVVVU", "UUUVU", #"UVV", "VVU", "UUU", "U",
#"VVVU", "UUVU", "VU", "VUUU", #"UUUV", "UVVV", "UV", "UVUU"};

#string LocCliffOp::get_name (void) const
#{
@@ -30,7 +27,9 @@ decompositions = ("xxxx", "xx", "zzxx", "zz", "zxx", "z", "zzz", "xxz",
#return string (paulinames[op & 0x03]) + (char) ('A' + op / 4);
#}

ab_names = {0: "IA"}
def get_name(i):
""" Get the human-readable name of this clifford """
return "IXYZ"[i & 0x03] + "ABCDEF"[i / 4]


def find_clifford(needle, haystack):


+ 1
- 1
abp/graphstate.py Voir le fichier

@@ -172,7 +172,7 @@ class GraphState(object):
rows = []
for key, vop in self.vops.items():
ngbh = " ".join(map(str, sorted(self.ngbh[key])))
vop = clifford.ab_names.get(vop, vop)
vop = clifford.get_name(vop)
s = "Vertex {}: VOp {}, neighbors {}".format(key, vop, ngbh)
rows.append(s)
return " \n".join(rows)+ " \n"


+ 19
- 0
tests/test_against_anders_and_briegel.py Voir le fichier

@@ -0,0 +1,19 @@
from abp.graphstate import GraphState
from anders_briegel import graphsim

def test_1():
N=10

a = graphsim.GraphRegister(N)
b = GraphState()

for i in range(N):
a.hadamard(i)
b.add_vertex(i)
b.act_hadamard(i)

for i in range(N-1):
a.cphase(i, i+1)
b.act_cz(i, i+1)

assert a.get_adj_list() == b.adj_list()

+ 7
- 0
tests/test_clifford_names.py Voir le fichier

@@ -0,0 +1,7 @@
from abp import clifford

def test_names():
""" Test the naming scheme """
for i in range(24):
clifford.get_name(i)
assert clifford.get_name(16)=="IE"

+ 8
- 0
tests/test_quantum.py Voir le fichier

@@ -0,0 +1,8 @@
from abp.graphstate import GraphState

def test_logic_101():
""" Some really simple tests """
g = GraphState()
g.act_local_rotation_by_name(0, "hadamard")
#print g.


Chargement…
Annuler
Enregistrer