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

full_reduce scalar edge case #272

Open
y-richie-y opened this issue Sep 11, 2024 · 1 comment
Open

full_reduce scalar edge case #272

y-richie-y opened this issue Sep 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@y-richie-y
Copy link
Contributor

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?

@jvdwetering
Copy link
Collaborator

Hhmm, that is an interesting edge case. What might be happening is that in the second case none of the rewrite rules in full_reduce match, and hence the method in the Graph that gets rid of scalar nodes also does not get called. This could be fixed by having a final round of removing scalar spiders at the end of full_reduce

@jvdwetering jvdwetering added the bug Something isn't working label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants