Skip to content

fix: Raise exception for probs with observable#280

Open
speller26 wants to merge 9 commits intomainfrom
probs
Open

fix: Raise exception for probs with observable#280
speller26 wants to merge 9 commits intomainfrom
probs

Conversation

@speller26
Copy link
Member

Issue #, if available:
#279

Description of changes:

Testing done:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@speller26 speller26 requested a review from a team as a code owner October 24, 2024 22:41
@codecov
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (46c674d) to head (f0c92eb).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #280   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines         1256      1258    +2     
  Branches       179       180    +1     
=========================================
+ Hits          1256      1258    +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


if return_type is ObservableReturnTypes.Probability:
if observable:
raise qml.DeviceError("Probability result type not supported for observables")
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks to be causing some issues for the tests. Is this the expected outcome now?

Copy link
Contributor

Choose a reason for hiding this comment

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

So at the moment the pl-device-tests are xfailing the hadamard gradient tests due to the incorrect results. We may instead need to xfail at a different location as now we get an error on execution, instead of on result comparison:

https://github.com/PennyLaneAI/pennylane/blob/883c3ed0a66d06841e074c90f59317972af36cee/pennylane/devices/tests/test_gradients_autograd.py#L141

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like the device tests are still failing; is there a workaround I can use?

@speller26 speller26 linked an issue Aug 22, 2025 that may be closed by this pull request
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.

Measuring probabilities in the basis of an observable

3 participants