Skip to content

feat: add OpenEntropy source and ECDF amplifier from PR #4#7

Merged
alchemystack merged 2 commits intomainfrom
evan-pr-a676
Mar 27, 2026
Merged

feat: add OpenEntropy source and ECDF amplifier from PR #4#7
alchemystack merged 2 commits intomainfrom
evan-pr-a676

Conversation

@alchemystack
Copy link
Copy Markdown
Owner

Summary

  • Incorporates the OpenEntropy entropy source and ECDF amplifier from PR Add OpenEntropy entropy source and ECDF amplification #4 with CI fixes
  • Moves openentropy from hard runtime dependency to optional extra (pip install qr-sampler[openentropy]), fixing install failures on Python 3.10/3.11/3.13 where no pre-built wheel exists
  • Removes assert in ecdf.py that triggered bandit B101, replacing with a type-narrowing comment (invariant already enforced by _calibrated guard)
  • Applies ruff format to new files to pass lint checks

Changes

  • New: src/qr_sampler/amplification/ecdf.py — ECDF-based signal amplifier (non-parametric, calibration-based)
  • New: src/qr_sampler/entropy/openentropy.py — OpenEntropy hardware entropy source with graceful degradation
  • New: tests/test_amplification/test_ecdf.py — ECDF amplifier tests including KS-test uniformity
  • New: tests/test_entropy/test_openentropy.py — OpenEntropy tests (fully mocked, no install needed)
  • New: deployments/openentropy/ — Deployment profile with .env.example and README
  • Modified: pyproject.toml — optional [openentropy] extra, entry point, mypy override
  • Modified: config.pyecdf_calibration_samples, oe_* config fields
  • Modified: processor.py — ECDF calibration wiring via hasattr(amplifier, "calibrate")
  • Modified: README.md, tests/test_config.py — docs and config test coverage

CI fixes applied (vs original PR #4)

  1. openentropy moved to optional dep — tests no longer fail building Rust on 3.10/3.11/3.13
  2. ruff format applied — lint check passes
  3. assert removed in ecdf.py — bandit security scan passes

Test plan

  • All existing tests pass unchanged
  • New ECDF tests pass (calibration, amplification, KS-test uniformity, bias correction)
  • New OpenEntropy tests pass (fully mocked — no openentropy install required)
  • ruff check and ruff format --check pass
  • bandit -r src/ -q passes clean
  • mypy --strict src/ passes

Closes #4

Integrate OpenEntropy hardware entropy source and ECDF signal amplifier
from ereid7's PR #4, with fixes for CI failures:

- Move openentropy to optional dependency (was breaking Python 3.10/3.11/3.13)
- Fix ruff formatting on openentropy.py and test_openentropy.py
- Remove bandit-flagged assert in ecdf.py (invariant enforced by _calibrated)
- Add ECDF calibration wiring in processor.py
- Optimize _to_numpy with is_cpu check to avoid unnecessary .cpu() calls
- Add oe_* config fields, entry point, mypy override, and tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Narrow _sorted_means with a local variable + None check instead of
type: ignore comments, satisfying mypy --strict.
@alchemystack alchemystack merged commit 9a81540 into main Mar 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant