pyzx icon indicating copy to clipboard operation
pyzx copied to clipboard

`full_reduce` scalar edge case

Open y-richie-y opened this issue 5 months ago • 1 comments

These examples are ran on the version of pyzx on pip:

In this example the right thing happens and we get (1 + 1j)

from pyzx import Graph, full_reduce
g = Graph()
g.add_vertex(ty=1, phase=0.5)
g.add_vertex(ty=1, phase=0)
g.add_edge((0, 1))
full_reduce(g)
print(g.scalar.to_number())

but in this example full_reduce does not reduce the diagram fully and the scalar is still 1:

from pyzx import Graph, full_reduce
g = Graph()
g.add_vertex(ty=1, phase=1)
full_reduce(g)
print(g.scalar.to_number())

This could be intended behaviour, but what is the "correct" way to reduce a pyzx diagram to a scalar?

y-richie-y avatar Sep 11 '24 05:09 y-richie-y