Sfoglia il codice sorgente

Needed to actually `return`

master
Pete Shadbolt 8 anni fa
parent
commit
19972159e5
2 ha cambiato i file con 10 aggiunte e 17 eliminazioni
  1. +2
    -3
      abp/graphstate.py
  2. +8
    -14
      tests/test_measurement.py

+ 2
- 3
abp/graphstate.py Vedi File

@@ -122,7 +122,6 @@ class GraphState(object):
old_basis = basis
ha = clifford.conjugation_table[self.node[node]["vop"]]
basis, phase = clifford.conjugate(basis, ha)
print basis, phase
assert phase in (-1, 1) # TODO: remove

# TODO: wtf
@@ -177,8 +176,8 @@ class GraphState(object):

for n in a - {friend}:
self.toggle_edge(friend, n)
return result





+ 8
- 14
tests/test_measurement.py Vedi File

@@ -1,22 +1,16 @@
from abp import GraphState
from anders_briegel import graphsim

def test_z_measurement():
def test_measurements():
g = GraphState([0])
assert g.measure_z(0, 0) == 0
assert g.measure_z(0, 1) == 1

def test_y_measurement():
g = GraphState([0])
assert g.measure_y(0, 0) == 0
assert g.measure_y(0, 1) == 1

print g
assert all(g.measure(0, "pz") == 0 for i in range(100)), "Measuring |0> in Z gives 0"


#def test_z_measurement_against_ab():
#for i in range(10):
#a = graphsim.GraphRegister(1)
#b = GraphState()
#b.add_node(0)
def test_z_measurement_against_ab():
for i in range(10):
a = graphsim.GraphRegister(1)
b = GraphState()
b.add_node(0)
#print a.measure(0, graphsim.lco_Z)
#print b.measure(0, "pz")

Loading…
Annulla
Salva