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: Use observable targets for targetless results #1025

Merged
merged 3 commits into from
Aug 28, 2024
Merged

fix: Use observable targets for targetless results #1025

merged 3 commits into from
Aug 28, 2024

Conversation

speller26
Copy link
Member

Issue #, if available:

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 August 26, 2024 23:42
Copy link

codecov bot commented Aug 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (93f450b) to head (e575e83).
Report is 26 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1025   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          135       135           
  Lines         9037      9033    -4     
  Branches      2030      2029    -1     
=========================================
- Hits          9037      9033    -4     

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

Comment on lines -216 to -235
)
elif isinstance(observable, Sum): # nested target
if len(target) != len(observable.summands):
raise ValueError(
"Sum observable's target shape must be a nested list where each term's "
"target length is equal to the observable term's qubits count."
)
self._target = [QubitSet(term_target) for term_target in target]
for term_target, obs in zip(self._target, observable.summands):
if obs.qubit_count != len(term_target):
if self._target:
if isinstance(observable, Sum): # nested target
if len(target) != len(observable.summands):
raise ValueError(
"Sum observable's target shape must be a nested list where each term's "
"target length is equal to the observable term's qubits count."
)
elif self._observable.qubit_count != len(self._target):
raise ValueError(
f"Observable's qubit count {self._observable.qubit_count} and "
f"the size of the target qubit set {self._target} must be equal"
)
elif self._observable.qubit_count != len(self.ascii_symbols):
Copy link
Member Author

Choose a reason for hiding this comment

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

Lines 217-237 are identical to lines 213-233 in the change; all I've done is indent one level

@speller26 speller26 requested a review from shpface August 28, 2024 17:14
@speller26 speller26 merged commit 8f4e88f into main Aug 28, 2024
26 checks passed
@speller26 speller26 deleted the targets branch August 28, 2024 19:16
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.

2 participants