Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use VertexType constants in tensor.py. #170

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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