Open
Conversation
Previously, first averaged over shots, then averaged over twirls (or other specified axes). This was complicated, because we needed to keep track of how many shots were accepted by postselection in order to propagate uncertainty properly later when averaging over twirls. Likewise we needed to keep track of PEC signs (`pauli_signs`). Now, we first flatten `avg_axis` (typically the twirl axis) into the shots axis, then do all averaging + postselection at once. This avoids needing to work with `weights`. This also avoids the situation where postselection rejects all shots on a single twirl, resulting in `nan` for the average of all twirls (particularly problematic when approaching the theoretically-optimal case of 1 shot per twirl).
`np.any` seems like a more readable version of `np.logical_or.reduce` here. The `np.asarray` call seems to be vestigial.
Pull Request Test Coverage Report for Build 23020221462Details
💛 - Coveralls |
caleb-johnson
approved these changes
Mar 12, 2026
Collaborator
caleb-johnson
left a comment
There was a problem hiding this comment.
This LGTM, thanks!
Replace a few lines in the optional, empirical estimate of `gamma` with a single equivalent line. Reminder that this empirical estimate of `gamma` is still unreliable as it can diverge or be negative.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Main changes are in the first commit. Slightly edited version of its commit message: