Skip to content
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

Merged
merged 11 commits into from
Apr 19, 2024

Conversation

PietropaoloFrisoni
Copy link
Contributor

@PietropaoloFrisoni PietropaoloFrisoni commented Apr 17, 2024

Context: qml.ParticleConservingU1 and qml.ParticleConservingU2 cannot be initialized with their default value for the initial_state argument (the default value is None).

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]

Copy link

codecov bot commented Apr 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.66%. Comparing base (016d2cc) to head (66ffeee).

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.
📢 Have feedback on the report? Share it here.

@PietropaoloFrisoni PietropaoloFrisoni marked this pull request as ready for review April 18, 2024 15:47
Copy link
Contributor

@dwierichs dwierichs left a 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.

doc/releases/changelog-dev.md Outdated Show resolved Hide resolved
@PietropaoloFrisoni
Copy link
Contributor Author

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

Copy link
Contributor

@astralcai astralcai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎸

@PietropaoloFrisoni PietropaoloFrisoni merged commit bb672a3 into master Apr 19, 2024
38 checks passed
@PietropaoloFrisoni PietropaoloFrisoni deleted the Bugfix/Initializing_ParticleConservingU1/2 branch April 19, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants