Repository navigation
Reject unsorted t in munge_data for matrix/N-d u - #623
ChrisRackauckas-Claude wants to merge 1 commit into
Conversation
The vector `munge_data` method checks `issorted(t)` and errors on unsorted input, but the matrix and N-d methods did not, so `LinearInterpolation([1 2 3 4; 1 2 3 4], [1,3,2,4])(2.5)` silently returns a wrong value (`[1.75, 1.75]`) instead of erroring. Add the same `issorted` check to both methods. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude <noreply@anthropic.com> Agent-Harness: Claude Code Agent-Model: claude-sonnet-5 Agent-Session: https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv
Independent review (Devin CLI 3000.11.3, model fusion-claude-opus-5-5-high-sidekick-swe-2-medium): CHANGES, risk low. Full reviewVERDICT: CHANGES The code change is correct, and I confirmed the failing-before/passing-after claim by running it. The only blocking item is a three-line test comment that breaks the binding comment rules. Once it is removed, this can be merged. Blocking findings
Non-blocking findings
What I ranAll runs used Julia 1.11 (
What I did not verify
🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (review), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium |
What changed and why
munge_datafor vectoruchecksissorted(t)at construction and raisesa clear
ArgumentErrorfor unsortedt. The matrix (AbstractMatrix) andN-d (
AbstractArray{T,N}) overloads ininterpolation_utils.jlhave nosuch check, so an unsorted
tis accepted silently and every type thatstores
uin matrix/array form returns wrong values without any warning.This PR adds the same
issorted(t; by = ForwardDiff.value)check (andArgumentErrorwith the same message used by the vector method) to boththe matrix and N-d
munge_datamethods.Failing before / passing after
Before (unmodified
master, commitb98db80):LinearInterpolation([1 2 3 4; 1 2 3 4], [1, 3, 2, 4])(2.5)silentlyreturns
[1.75, 1.75]on master —tis unsorted and the result isconstructed as if it were sorted, with no error.
New test
"munge_data rejects unsorted t for matrix/N-d u"intest/interpolation_tests.jlconstructs the same matrix case plus anN-d array case and asserts both throw
ArgumentError. This test fails(no error, wrong value returned) against unmodified master and passes
with the fix.
What was not verified
munge_data(u, t)call sites acrossinterpolation_caches.jl/online.jlindividually; they all funnelthrough the two
munge_datamethods touched here, so the fix appliesuniformly, but only
LinearInterpolationwas exercised directly in thenew test.
Core/QAgroups were run on Julia 1.12 and 1.10 (lts);prewas notrun.
Anything a reviewer should push back on
The error message text is copy-pasted from the vector method's
non-inversed-argument branch (it does not include the "arguments
inversed" hint, since that heuristic doesn't obviously generalize to
matrix/N-d
u). Worth a second look at whether that hint should alsoapply here.
Please ignore until reviewed by @ChrisRackauckas.
Risk assessment
munge_data(U::AbstractMatrix, t)andmunge_data(U::AbstractArray{T,N}, t)ininterpolation_utils.jl, usedby every interpolation type's matrix/N-d
uconstructor. Only rejectsinput that was already silently wrong; no change to accepted (sorted)
input. No public API signature change.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv
Breaking change
Breaking: the exported constructors (
LinearInterpolationand the others using these overloads) now throwArgumentErrorfor unsorted time domains that the current release accepts (with wrong results). This is a public behavior change and needs a major bump (Project.toml is still 10.1.3), or Chris's explicit call that it ships as a bug fix. The sorted-domain requirement should also be documented. Flagged by the independent review (codex-cli gpt-6.1-sol).🤖 Posted by an AI agent — harness: Claude Code 2.1.301 · model: claude-opus-5-5
Conversation: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq
Risk assessment (independent review, Codex gpt-6.1-sol, head fa5bf28)
munge_dataoverload, including LinearInterpolation, LagrangeInterpolation and spline constructors. Sorted ordinary numeric inputs tested here retain their results; callers using unsorted domains now receive an exception, including callers whose full-degree polynomial interpolation was correct.git diff origin/HEAD...HEAD, the PR body/comments, and related issue 427 (the PR has no linked issue). Archived default branch898d88ec6630d7bcd2886172ac81fa0fcf3e89e7and headfa5bf2878a6bb818009aa1af1552f860a923ec98into scratch. Ranpython3 scratch/run.py, which sequentially instantiated those copies and rantimeout 3600 julia --project=<scratch/base or scratch/head> <scratch/regression.jl or scratch/probes.jl>using Julia 1.12.4, the requested depot and four threads. The verbatim new testset failed on base: 2 failures, Expected: ArgumentError / No exception thrown; head: 2/2 pass. Analytic linear interpolation and knot-translation ForwardDiff tests: 4/4 pass on each revision. The separate Lagrange probe returned the exact quadratic values on base and ArgumentError on head. Logs and scripts are inscratch/.git diff --check origin/HEAD...HEADpassed. All 21 head check-runs reported success; there was no failing check requiring comparison with the default branch. Read the successful Extensions job log: Mooncake 769/769, Zygote 29470/29470. No dependency, exported-name, skipped-test or tolerance changes occur in the diff; no new dependency-internal access is introduced.🤖 Posted by an AI agent — harness: Codex CLI 0.162.1 · model: gpt-6.1-sol
Conversation: local headless review run (no public session URL); transcript kept by the fleet master.