zxcalc / zxlive

A graphical tool for the ZX calculus
Apache License 2.0
47 stars 19 forks source link

Exception when moving around vertex in proof mode #310

Open jvdwetering opened 1 month ago

jvdwetering commented 1 month ago

Start with following graph: image Apply 'decompose hadamard' and then fuse the left Z-spider to get: image Now move one of the X-spiders. A disembodied pi/2 phase will appear and the following exception is thrown:

  File "C:\Users\jweteri\Documents\Projects\zxlive\zxlive\mainwindow.py", line 273, in tab_changed
    self.active_panel.update_colors()
  File "C:\Users\jweteri\Documents\Projects\zxlive\zxlive\editor_base_panel.py", line 94, in update_colors
    super().update_colors()
  File "C:\Users\jweteri\Documents\Projects\zxlive\zxlive\base_panel.py", line 111, in update_colors
    self.graph_scene.update_colors()
  File "C:\Users\jweteri\Documents\Projects\zxlive\zxlive\graphscene.py", line 194, in update_colors
    v.refresh()
  File "C:\Users\jweteri\Documents\Projects\zxlive\zxlive\vitem.py", line 123, in refresh
    self.update_shape()
  File "C:\Users\jweteri\Documents\Projects\zxlive\zxlive\vitem.py", line 192, in update_shape
    if self.ty == VertexType.H_BOX or self.ty == VertexType.Z_BOX:
       ^^^^^^^
  File "C:\Users\jweteri\Documents\Projects\zxlive\zxlive\vitem.py", line 110, in ty
    _ty: VertexType = self.g.type(self.v)
                      ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jweteri\Documents\Projects\zxlive\../pyzx\pyzx\graph\multigraph.py", line 359, in type
    return self.ty[vertex]
           ~~~~~~~^^^^^^^^
KeyError: 0
RazinShaikh commented 1 month ago

I have been able to reproduce the issue with the following simplest graph. Fusion does not seem necessary; first decompose hadamard and then move the rightmost x spider. The pi/2 is actually not disembodied. Somehow it becomes the phase of the boundary node.