• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Qiskit / qiskit-addon-sqd-hpc / 35272030931

17 Sep 2026 08:38PM UTC coverage: 81.132% (-0.1%) from 81.26%
35272030931

push

github

web-flow
Add distributional tests for NoReplacementSampler (#57)

The sampler previously had no direct test; it was exercised only
indirectly through the subsampling and configuration-recovery suites.
Add a dedicated test that verifies its distribution.

For small (n, k) the exact distribution over selected sets under the
sequential ("successive") weighted-without-replacement scheme is computed
by enumerating every ordered draw path (a product of renormalized
weights), and the sampler's empirical distribution is compared against it
with a log-likelihood-ratio (G) test.  Cases cover ascending, uniform,
dominant, zero-weight, k-near-n, and extreme-weight-spread inputs, plus a
check that a zero-weight index is never selected.

The RNG is fixed-seeded, so the test is deterministic (a regression check
on the distribution rather than a fresh random draw each run), and the
pass thresholds sit well beyond the chi-squared tail so a correct sampler
does not flake while a grossly wrong distribution still fails.

A header comment documents that this is the sequential scheme (as exposed
by NumPy, Julia StatsBase, and R), NOT inclusion-probability-proportional-
to-size -- testing against that wrong invariant is a classic way to
mistake a correct sampler for a broken one.

Assisted-by: Claude Opus 4.8 (1M context)

702 of 947 branches covered (74.13%)

Branch coverage included in aggregate %.

76 of 80 new or added lines in 1 file covered. (95.0%)

502 of 537 relevant lines covered (93.48%)

454817.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.37
/test/test_sample_without_replacement.cpp


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc