Repository navigation
Improve calculation correctness, testing, and repository reliability - #5
Merged
Merged
Conversation
- Add pytest test suite (tests/) covering calculate_pi against trusted pi digits, binary_split, verify_pi, verify_full, save_pi, CLI, and edge cases; 47 tests passing - Fix verify_pi: authoritative full-range check against known pi digits, eliminating false positives/negatives from an insufficient prefix - Fix guard-digit handling in calculate_pi: discard guard digits from the fractional end, never left-pad the integer part - Add argparse CLI (--digits, --output) with interactive fallback and explicit exit codes - Remove GMPY2 global precision mutation on import - Fix pie.py: move interactive execution into main() with __main__ guard - verify.py: retry/backoff, reuse local reference, optional SHA-256 integrity check, TTY-aware progress, remove dead code - .gitignore: exclude generated pi_*.txt and reference_pi.txt - Pin gmpy2; add requirements-dev.txt (pytest) - README: document CLI, legacy calculators (pi_v3.py/pie.py), license status pending owner decision - GitHub Actions CI: run pytest + end-to-end 1,000-digit calc/verify against a committed fixture (no large downloads) Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
zomop
force-pushed
the
arena/12014a9e-piproject
branch
from
November 22, 2026 19:59
bac7294 to
7edccc4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements 13 repository-quality improvements across correctness, testing,
reliability, reproducibility, and developer experience, without breaking
existing functionality. All work is on the feature branch
targeting .
Original problems
(e.g. 5 digits) were rejected and longer miscalculations sharing the
prefix were falsely accepted.
corruption.
backoff, reuse, or integrity check.
calculators undocumented.
Files changed
Modified:
(--digits/--output, exit codes), removed global GMPY2 mutation
TTY-aware progress, removed dead code
Added:
save_pi, CLI, edge-case tests
verify_full tests
Tests executed and actual results
============================= test session starts ==============================
platform linux -- Python 3.11.2, pytest-9.2.0, pluggy-1.7.0
rootdir: /home/user/PiProject
collected 47 items
tests/test_pi_project_v4.py .................................. [ 72%]
tests/test_verify.py ............. [100%]
============================== 47 passed in 0.07s ============================== → 47 passed, 0 failed.
Coverage includes calculate_pi against trusted pi digits (1–1000), an
independent decimal/Machin cross-check, binary_split base cases/sign/
associativity, verify_pi accept/reject/edge cases, verify_full
match/mismatch/length/formatting, save_pi, CLI (--digits/--output,
invalid input, interactive fallback), and import side effects.
Functional checks also ran: 5,000-digit calculation verified against the
trusted first-1,000-digit reference; pie.py and pi_v3.py still execute;
clean; no generated artifacts tracked.
Remaining limitations
that it validates structure only. Full reference comparison at scale is
handled by .
is hard-coded (see owner decision below).
to download size/time; covered by the committed 1,000-digit fixture.
Decisions requiring repository owner authorization
License (no LICENSE file added). The project describes itself as open
source and the README's License section notes a license file should be
included, but none exists. I intentionally did NOT select or add a license
(MIT or otherwise) without explicit authorization. Please add a
file (and confirm the README wording) when ready.
Potential compatibility concerns
(previously mixed Indonesian/English).
How many digits of pi would you like to calculate?
Input stream closed. is invoked
as ; scripts relying on the previous implicit
exit behavior should use the returned code.
Relax to if broader version support is desired.
Verification in CI
GitHub Actions runs ============================= test session starts ==============================
platform linux -- Python 3.11.2, pytest-9.2.0, pluggy-1.7.0
rootdir: /home/user/PiProject
collected 0 items / 2 errors
==================================== ERRORS ====================================
_________________ ERROR collecting tests/test_pi_project_v4.py _________________
ImportError while importing test module '/home/user/PiProject/tests/test_pi_project_v4.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/test_pi_project_v4.py:10: in
import pi_project_v4 as m
E ModuleNotFoundError: No module named 'pi_project_v4'
____________________ ERROR collecting tests/test_verify.py _____________________
ImportError while importing test module '/home/user/PiProject/tests/test_verify.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/test_verify.py:7: in
import verify as v
E ModuleNotFoundError: No module named 'verify'
=========================== short test summary info ============================
ERROR tests/test_pi_project_v4.py
ERROR tests/test_verify.py
!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!
============================== 2 errors in 0.09s =============================== plus an end-to-end 1,000-digit calculation
and verification against on every
push/pull request to . No large files are downloaded.