Skip to content

Add pytest suite, CI workflow, and hygiene fixes - #1

Merged
WhatsYourWhy merged 1 commit into
mainfrom
claude/repo-state-review-5xgu9n
Jul 10, 2026
Merged

Add pytest suite, CI workflow, and hygiene fixes#1
WhatsYourWhy merged 1 commit into
mainfrom
claude/repo-state-review-5xgu9n

Conversation

@WhatsYourWhy

Copy link
Copy Markdown
Owner

Summary

Follow-up from a repo state review: the core library was very testable but had no test suite or CI. This PR adds both, plus two small hygiene fixes. No library code changes.

  • tests/test_core.py (pytest, 4278 tests via parametrization):
    • carmichael_lambda fast path checked against the existing method="brute" oracle for n = 1..150
    • Semiprime identity C(p·q) = gcd(p−1, q−1) over odd-prime pairs
    • invariant_factors: sortedness, divisibility chain, product = φ(n), last factor = λ(n) for n = 2..299; order histograms of the abstract cyclic-product cross-checked against actual element_orders for selected n
    • is_carmichael against the known list below 10⁴ (561, 1105, 1729, 2465, 2821, 6601, 8911) and against the λ(n) | n−1 criterion for n < 3000
    • collapse_propagation_trace reproduces the THEOREM.md worked examples (1365 → C=48, 1729 → C=36), order-independence, and error cases
  • .github/workflows/ci.yml: runs pytest on push and pull request (stdlib-only imports, so no matplotlib needed in CI)
  • gcd_distribution_theory.py: fixed a stale module docstring — the mean-gcd heuristic is sum 1/phi(d) ~ A·log D (as the code and THEOREM.md state), not a convergent sum 1/phi(d)^2
  • .gitignore: added runs/ (the README CLI example's output dir) and pytest cache; fixed missing trailing newline

Verification

  • pytest tests/ -q — 4278 passed in ~4s
  • All five visualization scripts (wedge_envelopes.py, order_distributions.py, propagation.py, group_structure.py, gcd_distribution_theory.py) run without error; committed PNGs left untouched
  • CLI smoke test (python lambda_ratio_explorer.py --q-max 20) works

🤖 Generated with Claude Code

https://claude.ai/code/session_01898JobGjDfsgm93YW6jH6s


Generated by Claude Code

- tests/test_core.py: brute-force oracle check for carmichael_lambda,
  semiprime gcd identity, invariant-factor structure cross-checked
  against actual element orders, Korselt criterion vs known Carmichael
  numbers below 10^4, and the THEOREM.md worked propagation examples
- .github/workflows/ci.yml: run pytest on push and pull request
- gcd_distribution_theory.py: fix stale module docstring (the mean-gcd
  heuristic is sum 1/phi(d) ~ A log D, not a convergent sum 1/phi(d)^2)
- .gitignore: ignore runs/ output dir and pytest cache, fix missing
  trailing newline

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01898JobGjDfsgm93YW6jH6s
@WhatsYourWhy
WhatsYourWhy marked this pull request as ready for review July 10, 2026 17:43
@WhatsYourWhy
WhatsYourWhy merged commit 2f19c1d into main Jul 10, 2026
2 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.

2 participants