-
Notifications
You must be signed in to change notification settings - Fork 621
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
Fix Identity.__repr__
bug
#6506
Conversation
Hello. You may have forgotten to update the changelog!
|
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.
Now LGTM! Let's see if CI complains anymore
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6506 +/- ##
=======================================
Coverage 99.34% 99.34%
=======================================
Files 455 456 +1
Lines 43193 43258 +65
=======================================
+ Hits 42909 42974 +65
Misses 284 284 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Mudit Pandey <[email protected]>
**Context:** Prior to this fix, the `repr` for `Identity` was incorrectly indexing `self.wires` at zero. This returned incorrect string representations. ```python >>> repr(qml.I([0, 1, 2, 3]) 'I(0)' ``` This was potentially not caught as the `__repr__` method was not being tested. After this fix, the entire `self.wires` attribute is being processed. This returns the intended string representations of the operator, ```python >>> repr(qml.I([0, 1, 'a', 3]) 'I([0,1,'a',3])' >>> repr(qml.I([0]) 'I(0)' >>> repr(qml.I()) 'I()' ``` **Description of the Change:** 1. Corrected the handling of `self.wires` in `Identity.__repr__`. 2. Added a test to `test_identity.py` to make sure the string representation is accurate. **Benefits:** Code accuracy and clarity. **Possible Drawbacks:** N/A Fixes [sc-77328] --------- Co-authored-by: Mudit Pandey <[email protected]>
Context:
Prior to this fix, the
repr
forIdentity
was incorrectly indexingself.wires
at zero. This returned incorrect string representations.This was potentially not caught as the
__repr__
method was not being tested.After this fix, the entire
self.wires
attribute is being processed. This returns the intended string representations of the operator,Description of the Change:
self.wires
inIdentity.__repr__
.test_identity.py
to make sure the string representation is accurate.Benefits: Code accuracy and clarity.
Possible Drawbacks: N/A
Fixes [sc-77328]