Skip to content

Commit

Permalink
Fix error arising from using .value
Browse files Browse the repository at this point in the history
  • Loading branch information
boldar99 committed Jun 25, 2024
1 parent 06a66f2 commit 2ee6e36
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pyzx/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def spider(g: BaseGraph[VT,ET], matches: List[MatchSpiderType[VT]]) -> RewriteOu
if v0 == w: continue
e = (v0,w)
if e not in etab: etab[e] = [0,0]
etab[e][g.edge_type(g.edge(v1,w)).value - 1] += 1
etab[e][g.edge_type(g.edge(v1,w)) - 1] += 1
return (etab, rem_verts, [], True)

def unspider(g: BaseGraph[VT,ET], m: List[Any], qubit:FloatInt=-1, row:FloatInt=-1) -> VT:
Expand Down Expand Up @@ -363,7 +363,7 @@ def w_fusion(g: BaseGraph[VT,ET], matches: List[MatchSpiderType[VT]]) -> Rewrite
w = v0_out
e = (v0_out, w)
if e not in etab: etab[e] = [0,0]
etab[e][g.edge_type(g.edge(v1_out, w)).value - 1] += 1
etab[e][g.edge_type(g.edge(v1_out, w)) - 1] += 1
return (etab, rem_verts, [], True)


Expand Down
2 changes: 1 addition & 1 deletion pyzx/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def tensorfy(g: 'BaseGraph[VT,ET]', preserve_scalar:bool=True) -> np.ndarray:
raise ValueError("Vertex %s has non-ZXH type but is not an input or output" % str(v))
nn = list(filter(lambda n: rows[n]<r or (rows[n]==r and n<v), neigh)) # TODO: allow ordering on vertex indices?
ety = {n:g.edge_type(g.edge(v,n)) for n in nn}
nn.sort(key=lambda n: ety[n].value)
nn.sort(key=lambda n: ety[n])
for n in nn:
if ety[n] == EdgeType.HADAMARD:
t = np.tensordot(t,had,(0,0)) # Hadamard edges are moved to the last index of t
Expand Down

0 comments on commit 2ee6e36

Please sign in to comment.