docs: fix decoherence noise example missing wrap_in_numshots_loop #1844
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.
Fixes #1402
Summary
The "Adding Decoherence Noise" documentation example was missing a call to
wrap_in_numshots_loop(1000)before executing the quantum program, causing the statistical calculations to be performed on only a single measurement instead of 1000.Changes
noisy.wrap_in_numshots_loop(1000)beforeqc.run(noisy)in the decoherence noise exampleAnalysis
Without
wrap_in_numshots_loop(), programs run with the defaultnum_shots=1, producing a bitstrings array of shape(1, 2). The example then computesnp.mean(bitstrings, axis=0)which averages over a single sample, making the statistics meaningless.This fix matches the pattern used in all other examples in the same documentation file:
wrap_in_numshots_loop(trials)wrap_in_numshots_loop(trials)wrap_in_numshots_loop()Note on T2 Parameter
The T2 parameter was left as
T2=t1/2, which:T2=2*t1(which is the theoretical maximum)The issue originally reported T2 as missing, but it was already added in a previous commit (likely during PR #1574 "Add doctests"), though the
wrap_in_numshots_loopwas still missing.Testing
Verified that:
num_shots = 1(confirmed inpyquil/quil.py:140)wrap_in_numshots_loop()beforeqc.run()(seetest/unit/test_quantum_computer.py)bitstrings.shape == (num_shots, num_qubits)