Skip to content

Conversation

@pavoljuhas
Copy link
Collaborator

Avoid possible KeyError in test_process_pauli_measurement_results_raises_error_on_missing_calibration

Problem: Random Pauli strings generated in the test may not contain all qubits
as is assumed in the empty_calibration_result_dict key.

Solution: Make dictionary with the qubits present in Pauli strings.

Fixes spurious test failure

pytest --randomly-seed=532866775 \
  cirq-core/cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation_test.py \
  -k test_process_pauli_measurement_results_raises_error_on_missing_calibration

Also fix

  • unnecessarily repeated list construction
  • unintentional dropping of circuits in a loop
  • Nit - sync docstring with function arguments

…s_error_on_missing_calibration

Problem: Random Pauli strings generated in the test may not contain all possible qubits
causing KeyError for the assumed `empty_calibration_result_dict`.

Solution: Make dictionary for the qubits occuring in Pauli strings.

Fixes spurious test failure

  pytest --randomly-seed=532866775 \
      cirq-core/cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation_test.py \
      -k test_process_pauli_measurement_results_raises_error_on_missing_calibration
Rewrite so that `test_circuits` contains 3 circuits instead of 1.
@pavoljuhas pavoljuhas requested review from a team and vtomole as code owners July 2, 2025 01:58
@github-actions github-actions bot added the size: S 10< lines changed <50 label Jul 2, 2025
@pavoljuhas
Copy link
Collaborator Author

pavoljuhas commented Jul 2, 2025

@ddddddanni - can you PTAL? This should prevent flake as in https://github.com/quantumlib/Cirq/actions/runs/16012035778/job/45171597863?pr=7457.

[NB - can be reviewed commit-by-commit]

@pavoljuhas pavoljuhas requested a review from NoureldinYosri July 2, 2025 02:03
@codecov
Copy link

codecov bot commented Jul 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.68%. Comparing base (e34da07) to head (178213c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7459   +/-   ##
=======================================
  Coverage   98.68%   98.68%           
=======================================
  Files        1092     1092           
  Lines       96546    96542    -4     
=======================================
+ Hits        95272    95273    +1     
+ Misses       1274     1269    -5     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ddddddanni
Copy link
Collaborator

@ddddddanni - can you PTAL? This should prevent flake as in https://github.com/quantumlib/Cirq/actions/runs/16012035778/job/45171597863?pr=7457.

[NB - can be reviewed commit-by-commit]

Thanks for fixing it!! Looks good to me.

@pavoljuhas pavoljuhas added this pull request to the merge queue Jul 2, 2025
Merged via the queue into quantumlib:main with commit f7f54e2 Jul 2, 2025
35 checks passed
@pavoljuhas pavoljuhas deleted the fix-pauli-string-readout-mitigation-test-flake branch July 2, 2025 18:24
ddddddanni added a commit to ddddddanni/Cirq that referenced this pull request Jul 15, 2025
…st (quantumlib#7459)

Avoid possible KeyError in
`test_process_pauli_measurement_results_raises_error_on_missing_calibration`

Problem: Random Pauli strings generated in the test may not contain all
qubits
as is assumed in the `empty_calibration_result_dict` key.

Solution: Make dictionary with the qubits present in Pauli strings.

Fixes spurious test failure

```
pytest --randomly-seed=532866775 \
  cirq-core/cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation_test.py \
  -k test_process_pauli_measurement_results_raises_error_on_missing_calibration
```

Also fix

- unnecessarily repeated list construction
- unintentional dropping of circuits in a loop
- Nit - sync docstring with function arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S 10< lines changed <50

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants