-
Notifications
You must be signed in to change notification settings - Fork 141
Fix #179: added copy_simp and supplementarity_simp to full_reduce #332
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
Merged
+58
−8
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c93a873
added copy_simp to full_reduce
lara-madison 0adf475
added supplementarity_simp to full_reduce
lara-madison aca6907
doc string fixed
lara-madison ab3f432
added tests for copy_simp and full_reduce
lara-madison 7ec130a
Merge branch 'master' into issue/179
lara-madison c409910
fixed simple_extract test
lara-madison e0d5f38
improved copy tests
lara-madison 1d59897
fixed docstring format of full_reduce
lara-madison File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
from fractions import Fraction | ||
from pyzx.generate import cliffordT | ||
from pyzx.simplify import * | ||
from pyzx.simplify import supplementarity_simp, to_clifford_normal_form_graph | ||
from pyzx.simplify import supplementarity_simp, to_clifford_normal_form_graph, copy_simp | ||
from pyzx import compare_tensors | ||
from pyzx.generate import cliffordT | ||
|
||
|
@@ -159,6 +159,52 @@ def test_to_clifford_normal_form_graph(self): | |
g0 = g.copy() | ||
to_clifford_normal_form_graph(g) | ||
self.assertTrue(compare_tensors(g0, g, preserve_scalar=True)) | ||
|
||
def test_copy_simp(self): | ||
g = Graph() | ||
|
||
v0 = g.add_vertex(VertexType.Z, 0, 0) | ||
v1 = g.add_vertex(VertexType.X, 0, 1) | ||
g.add_edge((v0, v1)) | ||
v2 = g.add_vertex(VertexType.BOUNDARY, 0, 3) | ||
g.add_edge((v1, v2)) | ||
v3 = g.add_vertex(VertexType.BOUNDARY, 1, 3) | ||
g.add_edge((v1, v3)) | ||
|
||
g1 = g.copy() | ||
to_gh(g1) | ||
copy_simp(g1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should probably also assert that copy_simp actually simplified the graph, and that this is not a 'noop'. |
||
|
||
g1.auto_detect_io() | ||
g.auto_detect_io() | ||
|
||
self.assertFalse(g.num_vertices() != g1.num_vertices()) | ||
self.assertTrue(g1.num_vertices() == 4) | ||
self.assertTrue(compare_tensors(g1.to_tensor(),g.to_tensor())) | ||
|
||
|
||
def test_copy_simp_full_reduce(self): | ||
g = Graph() | ||
|
||
v0 = g.add_vertex(VertexType.Z, 0, 0) | ||
v1 = g.add_vertex(VertexType.X, 0, 1) | ||
g.add_edge((v0, v1)) | ||
v2 = g.add_vertex(VertexType.BOUNDARY, 0, 3) | ||
g.add_edge((v1, v2)) | ||
v3 = g.add_vertex(VertexType.BOUNDARY, 1, 3) | ||
g.add_edge((v1, v3)) | ||
|
||
g1 = g.copy() | ||
to_gh(g) | ||
copy_simp(g) | ||
|
||
full_reduce(g1) | ||
g.auto_detect_io() | ||
g1.auto_detect_io() | ||
|
||
self.assertTrue(g.num_vertices() == g1.num_vertices()) | ||
self.assertTrue(compare_tensors(g1.to_tensor(),g.to_tensor())) | ||
|
||
|
||
|
||
qasm_1 = """OPENQASM 2.0; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.