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 sample measuring hamiltonians with a shot vector #4254

Merged
merged 4 commits into from
Jun 15, 2023

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Jun 14, 2023

[sc-40254]

Finite shot measurements of Hamiltonians and sums was not working with shot vectors. This PR adds shot vector coverage.

shots = Shots((100, 100))
state = create_initial_state((0,))
measure_with_samples(qml.expval(qml.PauliX(0)+qml.PauliY(0)), state,shots=shots)
(tensor(-0.06, requires_grad=True), tensor(-0.16, requires_grad=True))

@albi3ro albi3ro requested a review from eddddddy June 14, 2023 20:36
@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.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 Jun 14, 2023

Codecov Report

Merging #4254 (56fde34) into master (ccf24c6) will increase coverage by 99.78%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           master    #4254       +/-   ##
===========================================
+ Coverage        0   99.78%   +99.78%     
===========================================
  Files           0      352      +352     
  Lines           0    31733    +31733     
===========================================
+ Hits            0    31665    +31665     
- Misses          0       68       +68     
Impacted Files Coverage Δ
pennylane/devices/qubit/sampling.py 100.00% <100.00%> (ø)

... and 351 files with indirect coverage changes

Copy link
Contributor

@eddddddy eddddddy left a comment

Choose a reason for hiding this comment

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

LGTM 💯

@albi3ro albi3ro requested a review from a team June 15, 2023 13:00
@albi3ro albi3ro enabled auto-merge (squash) June 15, 2023 15:28
@timmysilv timmysilv added this to the v0.31 milestone Jun 15, 2023
@albi3ro albi3ro merged commit 8a75abd into master Jun 15, 2023
43 checks passed
@albi3ro albi3ro deleted the sampling_sum_shot_vector branch June 15, 2023 16:02
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.

None yet

4 participants