-
Notifications
You must be signed in to change notification settings - Fork 118
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
) | ||
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): |
There was a problem hiding this comment.
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
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
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.