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

Fix stateprep casting rules. #501

Merged
merged 15 commits into from
Sep 19, 2023
Merged

Fix stateprep casting rules. #501

merged 15 commits into from
Sep 19, 2023

Conversation

vincentmr
Copy link
Contributor

@vincentmr vincentmr commented Sep 15, 2023

Before submitting

Please complete the following checklist when submitting a PR:

  • All new features must include a unit test.
    If you've fixed a bug or added code that should be tested, add a test to the
    tests directory!

  • All new functions and code must be clearly commented and documented.
    If you do make documentation changes, make sure that the docs build and
    render correctly by running make docs.

  • Ensure that the test suite passes, by running make test.

  • Add a new entry to the .github/CHANGELOG.md file, summarizing the
    change, and including a link back to the PR.

  • Ensure that code is properly formatted by running make format.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context:
We currently have the following

@qml.qnode(qml.device("lightning.qubit", wires=2))
def circuit():
    qml.StatePrep(np.array([1, 0, 0, 0]), wires=[0, 1])
    return qml.state()

>>> [1 0 0 0]

why causes issues as the integer-valued state is not casted to complex.

Description of the Change:
Introduce ad hoc casting clause for integral types in Lightning.

Benefits:

Possible Drawbacks:

Related GitHub Issues:

@vincentmr vincentmr changed the title Cast stateprep to complex128 in doubt. Fix stateprep casting rules. Sep 15, 2023
@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit .github/CHANGELOG.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Sep 15, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (75701fc) 99.11% compared to head (6a28509) 99.13%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #501      +/-   ##
==========================================
+ Coverage   99.11%   99.13%   +0.01%     
==========================================
  Files         141      142       +1     
  Lines       16655    16798     +143     
==========================================
+ Hits        16507    16652     +145     
+ Misses        148      146       -2     
Files Changed Coverage Δ
pennylane_lightning/core/_version.py 100.00% <100.00%> (ø)
pennylane_lightning/core/lightning_base.py 100.00% <100.00%> (ø)
...ylane_lightning/lightning_qubit/lightning_qubit.py 94.53% <100.00%> (+1.98%) ⬆️

... and 13 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vincentmr vincentmr marked this pull request as ready for review September 15, 2023 18:49
@vincentmr vincentmr requested a review from a team September 15, 2023 18:50
Copy link
Contributor

@AmintorDusko AmintorDusko left a comment

Choose a reason for hiding this comment

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

Nice work! Thank you for that!

Co-authored-by: Amintor Dusko <[email protected]>
@vincentmr vincentmr requested a review from a team September 18, 2023 14:18
Copy link
Member

@mlxd mlxd left a comment

Choose a reason for hiding this comment

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

LGTM -- thanks

@vincentmr vincentmr merged commit 67aaaf6 into master Sep 19, 2023
@vincentmr vincentmr deleted the bugfix/stateprep branch September 19, 2023 20:46
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