Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

gh-162645: Round exact Decimal midpoint ties in statistics._decimal_sqrt_of_frac to even - #162699

Open
rxchitrx wants to merge 1 commit into
python:mainfrom
rxchitrx:fix/gh-162645-decimal-sqrt-tie
Open

rxchitrx wants to merge 1 commit into
python:mainfrom
rxchitrx:fix/gh-162645-decimal-sqrt-tie

Conversation

@rxchitrx

Copy link
Copy Markdown

Round exact midpoint ties in statistics._decimal_sqrt_of_frac() to the even neighbor using the active context's precision regardless of getcontext().rounding, matching Decimal.sqrt().

Summary of changes

  • Lib/statistics.py (_decimal_sqrt_of_frac): Compute the initial variance under ROUND_HALF_EVEN without Emin/Emax clipping when needed so variance.sqrt() starts within one step of the true root, then compare n/m against the exact squared midpoint and break exact ties to the even neighbor (measuring parity in units of the step size, including across power-of-10 boundaries).
  • Lib/test/test_statistics.py: Add regression tests covering the reported 11.5 -> 12 and 12.5 -> 12 cases at prec=2, prec=28, power-of-10 boundaries, all 8 rounding modes, subnormals, and Emin/Emax overflow handling.
  • Misc/NEWS.d/next/Library/: Add news entry.

@python-cla-bot

python-cla-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T18:33:02.403145Z 5697b28 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@picnixz
picnixz requested a review from rhettinger November 26, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant