Skip to content

Commit

Permalink
Merge pull request #170 from dlyongemallo/tensor_constants
Browse files Browse the repository at this point in the history
Use `VertexType` constants in tensor.py.
  • Loading branch information
jvdwetering authored Oct 20, 2023
2 parents aed3b78 + ea145d7 commit 635f829
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pyzx/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,25 @@ def tensorfy(g: 'BaseGraph[VT,ET]', preserve_scalar:bool=True) -> np.ndarray:
neigh = list(g.neighbors(v))
d = len(neigh)
if v in inputs:
if types[v] != 0: raise ValueError("Wrong type for input:", v, types[v])
if types[v] != VertexType.BOUNDARY: raise ValueError("Wrong type for input:", v, types[v])
continue # inputs already taken care of
if v in outputs:
if d != 1: raise ValueError("Weird output")
if types[v] != 0: raise ValueError("Wrong type for output:",v, types[v])
if types[v] != VertexType.BOUNDARY: raise ValueError("Wrong type for output:",v, types[v])
d += 1
t = id2
else:
phase = pi*phases[v]
if types[v] == 1:
if types[v] == VertexType.Z:
t = Z_to_tensor(d,phase)
elif types[v] == 2:
elif types[v] == VertexType.X:
t = X_to_tensor(d,phase)
elif types[v] == 3:
elif types[v] == VertexType.H_BOX:
t = H_to_tensor(d,phase)
elif types[v] == 4 or types[v] == 5:
elif types[v] == VertexType.W_INPUT or types[v] == VertexType.W_OUTPUT:
if phase != 0: raise ValueError("Phase on W node")
t = W_to_tensor(d)
elif types[v] == 6:
elif types[v] == VertexType.Z_BOX:
if phase != 0: raise ValueError("Phase on Z box")
label = get_z_box_label(g, v)
t = Z_box_to_tensor(d, label)
Expand Down

0 comments on commit 635f829

Please sign in to comment.