-
Notifications
You must be signed in to change notification settings - Fork 617
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
Bugfix: Cannot initialize ParticleConservingU1/2
with default init_state
#5535
Bugfix: Cannot initialize ParticleConservingU1/2
with default init_state
#5535
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5535 +/- ##
==========================================
- Coverage 99.67% 99.66% -0.01%
==========================================
Files 406 406
Lines 37928 37639 -289
==========================================
- Hits 37804 37514 -290
- Misses 124 125 +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.
Looks good to me, thanks for the fix, @PietropaoloFrisoni
Would there be any benefit in creating a numpy array directly, rather than a tuple, as the default value? Either way works for me.
@dwierichs That's what I did at first (see this commit), but I ended up changing my mind since the initial state is then converted to a tuple anyway |
…github.com/PennyLaneAI/pennylane into Bugfix/Initializing_ParticleConservingU1/2
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.
LGTM 🎸
Context:
qml.ParticleConservingU1
andqml.ParticleConservingU2
cannot be initialized with their default value for theinitial_state
argument (the default value isNone
).Description of the Change: If the
initial_state
argument is not specified, it is set to a tuple of zeros, which seems a reasonable choice for an initial state in physics. This modification occurs only if the initial state is not specified and the information is reported in the class's docstring.Benefits: The error is no longer raised when the initial state is not specified, and the class works with the default argument.
Possible Drawbacks: As mentioned above, this modification only occurs if the initial state is not specified and should not cause any issues.
Related GitHub Issues: #5522
[sc-61431]