-
Notifications
You must be signed in to change notification settings - Fork 8
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
ZXW Diagram implementation #92
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #92 +/- ##
===========================================
- Coverage 94.34% 82.88% -11.46%
===========================================
Files 11 16 +5
Lines 2085 2478 +393
===========================================
+ Hits 1967 2054 +87
- Misses 118 424 +306
☔ View full report in Codecov by Sentry. |
Thank you for the pull request; it looks great overall. I have a few minor suggestions. It seems that you have extended the |
This makes much more sense. I will change it accordingly. Thank you! |
Since we are implementing |
Since we want to separate the original implementation, we can also use algebraic data types to represent the node type and its parameters. An algebraic data type is a type that combines several data types in a type-stable way. An implementation of ADTs can be found in Expronicon. By using ADT pattern matching, as implemented in MLStyle, we can replace the |
The latest commits on ADT of |
Hello, @ChenZhao44 I have finished correcting for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks great. I only have two minor suggestions. Once you fix this, you can merge it.
(PiUnit(pu1, _), PiUnit(pu2, _)) && if pu1 isa Number && pu2 isa Number | ||
end => Parameter(Val(:PiUnit), pu1 + pu2) | ||
(PiUnit(pu1, _), PiUnit(pu2, _)) && if !(pu1 isa Number) || !(pu2 isa Number) | ||
end => Parameter(Val(:PiUnit), Expr(:call, :+, pu1, pu2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we should include the number type of the expr. See https://github.com/QuantumBFS/ZXCalculus.jl/blob/bbc19ab5ec0f1eb0b09ffa7a6e2976f60b625fbc/src/phase.jl#L30C35-L30C35
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much! I corrected the Expr
part. For the pattern matched above that, I declared the constructor of Parameter
as a parametric method. The type of pu
should be automatically matched like in the previous implementation link The test passed alright, I will merge the changes for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies, I just realized that I didn't push my last change to the branch before merging. I will add those changes to next branch's update.
end => Parameter(Val(:PiUnit), pu1 - pu2) | ||
(PiUnit(pu1, pu_t1), PiUnit(pu2, pu_t2)) && | ||
if !(pu1 isa Number) || !(pu2 isa Number) | ||
end => Parameter(Val(:PiUnit), Expr(:call, :-, pu1, pu2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed here too.
Implement
ZXWDiagram
.Moving functions under
zx_diagram.jl
toutils.jl
for reusing them forZXWDiagram
.