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

Fix pivot basic rewrite with new PyZX version #334

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
7 changes: 2 additions & 5 deletions zxlive/custom_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,8 @@ def filter_matchings_if_symbolic_compatible(matchings: list[Dict[VT, VT]], left:
for matching in matchings:
if len(matching) != len(left):
continue
try:
match_symbolic_parameters(matching, left, right)
new_matchings.append(matching)
except ValueError:
pass
match_symbolic_parameters(matching, left, right)
new_matchings.append(matching)
return new_matchings


Expand Down
5 changes: 1 addition & 4 deletions zxlive/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,7 @@ def save_diagram_dialog(graph: GraphT, parent: QWidget) -> Optional[tuple[str, F
file_path, selected_format = file_path_and_format

if selected_format in (FileFormat.QGraph, FileFormat.Json):
try:
graph.auto_detect_io()
except TypeError:
pass
graph.auto_detect_io()
data = graph.to_json()
elif selected_format == FileFormat.QASM:
try:
Expand Down
2 changes: 2 additions & 0 deletions zxlive/rewrite_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def do_rewrite(self, panel: ProofPanel) -> None:

try:
g, rem_verts = self.apply_rewrite(g, matches)
except ValueError as ex:
raise ex
except Exception as ex:
show_error_msg('Error while applying rewrite rule', str(ex))
return
Expand Down
15 changes: 6 additions & 9 deletions zxlive/rule_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,9 @@ def add_edge(self, u: VT, v: VT) -> None:
self.update_io_labels(self.graph_scene)

def update_io_labels(self, scene: EditGraphScene) -> None:
try:
scene.g.auto_detect_io()
for v in scene.g.vertices():
if v in scene.g.inputs():
scene.vertex_map[v].phase_item.setPlainText("in-" + str(scene.g.inputs().index(v)))
elif v in scene.g.outputs():
scene.vertex_map[v].phase_item.setPlainText("out-" + str(scene.g.outputs().index(v)))
except TypeError:
return
scene.g.auto_detect_io()
for v in scene.g.vertices():
if v in scene.g.inputs():
scene.vertex_map[v].phase_item.setPlainText("in-" + str(scene.g.inputs().index(v)))
elif v in scene.g.outputs():
scene.vertex_map[v].phase_item.setPlainText("out-" + str(scene.g.outputs().index(v)))
1 change: 1 addition & 0 deletions zxlive/vitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def g(self) -> GraphT:

@property
def ty(self) -> VertexType:
# https://github.com/zxcalc/zxlive/pull/281
_ty: VertexType = self.g.type(self.v)
return _ty

Expand Down
Loading