← Back to Pull requests

BUG: eval_chebyt, eval_chebyu, eval_legendre: fix odd integral `n` near `x = 0` #597

Open
unknown opened this pull request with 157 lines diff across 1 files
View on GitHub
unknown unknown commented on Nov 21, 2026 00:43 UTC
Author

Reference issue


No issue; found while porting xsf to Rust (https://github.com/jorenham/xsf-rust/pull/1701):

>>> from scipy.special import eval_chebyt
>>> eval_chebyt(5.0, 1e-10)  # should be 5e-10 up to rounding
5.000000413701855e-10

What does this implement/fix?


For real |x| < 1e-5 and odd integral double n (|n| <= 1000 for eval_chebyt and eval_chebyu, odd effective degree <= 300 after P_{-n-1} = P_n for eval_legendre), these now use the existing integer-degree implementations. The 2F1 series cancels for odd n near the origin, while those are accurate there. In sweeps against mpmath, the error never exceeded the old one by more than about 5 eps. eval_gegenbauer already does this for n >= 0.

Additional information


The new test fails on main with GCC and Clang (relative error up to 1e-6) and passes with the fix. eval_jacobi with alpha == beta has the same problem, but its integer path is also inaccurate near the origin; #603 fixes it.

AI Generation Disclosure


Claude Sonnet 5.5 (Claude Code) wrote the fix, the test, and this description, following the plan in this comment. GPT-6.2 Sol (Codex CLI) reviewed it.

Diff: 157 lines (+117 / -40) across 1 files Reviewer: jorenham Review duration: 14079m
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.38) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.38 · 157 lines diff across 1 files
0.38
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
42%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.303
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #597"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 43.0% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 38.3% (MEDIUM) · Higher = larger blast radius
38.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 43.0% · Lower = rushed or shallow review
43.0%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 21.8% · Safe to merge
21.8%
Repository