Skip to content

pynumerics: exact factorial oracles and timing checks as benchmarks - #151

Merged
HadenSmith merged 3 commits into
mainfrom
haden/pynumerics-factorial-oracle
Nov 11, 2026
Merged

HadenSmith merged 3 commits into
mainfrom
haden/pynumerics-factorial-oracle

Conversation

@HadenSmith

@HadenSmith HadenSmith commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The v2.3.0 PyPI publish run failed on its Windows, Python 3.11 test job in test_factorials_and_binomial_coefficients_match_scipy. That environment resolved SciPy 1.17.1, whose floating scipy.special.factorial is a gamma approximation that is off by up to 8e-14 relative (34!: SciPy 2.9523279903960253e38, exact 2.9523279903960416e38). pynumerics was the accurate side.

  • The factorial and binomial tests now compare with float(math.factorial(k)) and float(math.comb(n, k)), the exact integers rounded to double, so they no longer depend on the SciPy version or platform. Tolerances are unchanged.
  • The PR check then failed on a wall-clock assertion on the Windows runner (a bulk transfer measured 1.1x faster where the test asserts 10x). All 24 wall-clock comparisons in the pynumerics tests are now @pytest.mark.benchmark, deselected by default (pytest -m benchmark runs them). Where a test also checked results (bits equal to the scalar path, the same replicates, agreement with SciPy or scikit-learn), those checks stay in an unmarked functional test.
  • Test-only change, plus an AI disclosure statement in the root README; no library code changes.

Validation: ruff clean; Linux Docker wheel build and default pytest 5764 passed, 6 skipped, 27 deselected (benchmarks), 0 failed.

After merge

gh workflow run PythonPublish.yml -R USACE-RMC/Numerics --ref main -f release_tag=v2.3.0 -f publish_to_pypi=true, then approve the pypi environment.

🤖 Generated with Claude Code

…er values rounded to double instead of SciPy's gamma-based floating factorial, whose accuracy varies by SciPy version and platform
…ult; their correctness checks stay in the default run
@HadenSmith HadenSmith changed the title pynumerics: exact oracles for the factorial and binomial tests pynumerics: exact factorial oracles and timing checks as benchmarks Nov 11, 2026
@HadenSmith
HadenSmith merged commit f593d1f into main Nov 11, 2026
7 checks passed
@HadenSmith
HadenSmith deleted the haden/pynumerics-factorial-oracle branch November 11, 2026 18:00
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