← Back to Pull requests

Flip the odd-degree endpoint second derivative at z=-1 #285

Open
shaneraphel opened this pull request with 5 lines diff across 1 files
View on GitHub
shaneraphel shaneraphel commented on Sep 24, 2026 09:38 UTC
Author

Summary


assoc_legendre_p with diff_n=2 returns the wrong sign at z=-1 for odd degree. The second-derivative closed forms for m = 0, 2, 4 are the z=+1 values. At z=-1 those values pick up (-1)^n.

For n=3, m=0, P_3''(x) = 15x, so the endpoint is -15. The header returned +15. The same sign error shows up for m=2 (P_3^2 second derivative 90 at x=-1, header returned -90). Even degrees already match and are left alone. The m=-2 closed form does not match lpmv for n>2 at either endpoint, so this change does not touch it.

This is the routine behind SciPy special.assoc_legendre_p in scipy/scipy#26229.

Test plan


  • Compared the closed form with scipy.special.lpmv near both endpoints for n=2..7 and m in {0, 2, 4}. At n=3, m=0 the old form is +15 and the finite-difference value is -15. Multiplying by (-1)^n when z<0 and n is odd matches that sign. At z=+1 the form already matches (+15).

  • xsf's own test binary was not rebuilt here
  • Prepared with an AI assistant. I reviewed the header change and the endpoint comparison.

    Diff: 5 lines (+5 / -0) across 1 files Reviewer: fbourgey Review duration: 27214m
    All Vouch review confidence checks passed
    Residual risk 0.04 = Change Risk (0.14) × (1 − Review Confidence (0.68)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.14 · 5 lines diff across 1 files
    0.14
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.35 · 1 substantive comment(s)
    0.35
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    67%
    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
    Diff Size diff_size
    0.107
    Real PR Conversation Timeline
    2 items
    fbourgey fbourgey requested changes on Oct 04, 2026 14:37 UTC
    Changes Requested Reviewer

    thanks. can you add a regression test? there are some conflicts as well.

    Reviewers
    Assignees
    shaneraphel shaneraphel
    Labels
    risk: low confidence: 67.5% 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: 13.7% (LOW) · Higher = larger blast radius
    13.7%
    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: 67.5% · Lower = rushed or shallow review
    67.5%
    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: 4.5% · Safe to merge
    4.5%
    Repository