-
Notifications
You must be signed in to change notification settings - Fork 603
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
Set operations and tests added #5983
Conversation
Hello. You may have forgotten to update the changelog!
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5983 +/- ##
==========================================
- Coverage 99.66% 99.65% -0.01%
==========================================
Files 428 430 +2
Lines 41182 41193 +11
==========================================
+ Hits 41042 41052 +10
- Misses 140 141 +1 ☔ View full report in Codecov by Sentry. |
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.
Thanks @austingmhuang! would it also be possible to have union
, difference
, intersection
and symmetric_difference
methods? E.g.,
def union(self, other):
new_wires = set(self.labels) | set(other.labels)
return Wires(list(new_wires))
def __or__(self, other):
return self.union(other)
I know it's a bit more to add and have tests for, but this would be nice.
Other than that, looks great!
Yes, we're looking to add as many as possible of the typical Python set operations - though happy to discuss any that are particularly challenging. |
No worries I can add all the set operations, no challenge there :) |
Thanks @austingmhuang! 🤗 Feel free to tag me for review again when the time comes 👍 |
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
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.
Thanks Austin! My suggestions are minor. Just want to make the docstring code examples copy-pastable.
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
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.
Thanks @austingmhuang, looks good to me. Left some minor comments.
Context:
Set operations are useful for Wires and Registers and would be a welcome addition/feature in the PennyLane ecosystem
Description of the Change:
This PR implements the 4 set operations for Wires and you can access them with their respective operators (| & - ^) as well as comprehensive tests.
Benefits:
Nice syntactic sugar
Possible Drawbacks:
Related GitHub Issues:
[sc-67925]