Skip to content

Add None, Periodic and Reflective extrapolation and document N-D linear extrapolation - #111

Open
asinghvi17 wants to merge 5 commits into
SciML:mainfrom
asinghvi17:extrapolation
Open

asinghvi17 wants to merge 5 commits into
SciML:mainfrom
asinghvi17:extrapolation

Conversation

@asinghvi17

@asinghvi17 asinghvi17 commented Nov 12, 2026 •

Copy link
Copy Markdown

🤖 Automated comment from an AI agent running as @asinghvi17 — not written or reviewed by Anshul.

Adds the remaining DataInterpolations extrapolation modes:

  • None throws ExtrapolationError outside the grid.
  • Periodic and Reflective wrap or mirror the query point onto the grid. Odd derivatives flip sign on mirrored copies of a reflective axis.

Defaults are unchanged. It also documents and tests N-D Linear extrapolation, which already works as a tensor product with bilinear corners.

Extends the ExtrapolationType enum from #101 with the DataInterpolations modes it left out (towards #12), keeping the single per-dimension extrapolation keyword agreed there.

It also fixes make_out dispatch on Julia 1.10 for 3D calls with mixed argument types, e.g. itp(0.3, 1, 0.7f0) gave a MethodError; the signature is now Tuple{Vararg{Number, N_in}}.

🤖 Generated with Claude Code

https://claude.ai/code/session_014mFQHtrhbkjCL96BmvXjDA


🤖 Posted by an AI agent — harness: Claude 2.1.316 · model: claude-opus-5-5
Conversation: factory head hd_c55d7e33 on m_4242afb3ce622d22c2c40d9e9baf1f9a (no session URL)

…ntics

Complete the per-dimension `ExtrapolationType` options so they cover the
same modes as DataInterpolations.jl:

- `None` throws an `ExtrapolationError` when evaluating outside the grid of
  that dimension. Multi-point evaluation checks `t_eval` on the host, so
  constructing a dimension with out-of-range `t_eval` still works.
- `Periodic` and `Reflective` fold the query point onto the grid before
  index lookup and evaluation, including the precomputed indices and spline
  basis functions used by `eval_grid` and `eval_unstructured`. Odd
  derivatives along mirrored copies of a reflective axis change sign.

Defaults are unchanged (`Linear` for linear dimensions, `Constant` for
constant dimensions, `Extension` for splines). New modes are appended to
the enum so existing values keep their integer codes. Mode selection stays
an isbits enum compared by value, so evaluation remains allocation free for
linear and constant dimensions and has no dynamic dispatch on the mode.

Document the tensor-product semantics of `Linear` extrapolation in several
dimensions (sides continue with the boundary slope, corners pick up the
mixed partial terms) and add tests for 1D agreement with DataInterpolations
in every mode, 2D/3D sides and corners against the formula, derivative
continuity at the boundary, derivatives against finite differences outside
the grid, unchanged defaults and allocations.

Also accept heterogeneous input tuples in `make_out`, which failed to
dispatch on Julia 1.10 for three or more dimensions, e.g. when
ForwardDiff differentiates one coordinate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 4e5399d0-1eb6-44c0-ab1e-b8c3c4620652
Agent-Harness: Claude 2.1.319
Agent-Model: claude-opus-5-5
Agent-Session: factory task 4e5399d0-1eb6-44c0-ab1e-b8c3c4620652 on m_e7dafdb55d0afc98861a124723a9e3fd (no session URL)
@asinghvi17
asinghvi17 marked this pull request as ready for review November 12, 2026 01:27
Replace the large 3D and mixed-mode test matrices with seven focused
testsets: `None` throws outside the grid, `Periodic` and `Reflective`
match DataInterpolations in 1D (values and first derivative, including
`eval_grid`), a 2D `Linear` corner check against the tensor-product
formula, derivative continuity at the boundary, pinned default values,
the Julia 1.10 `make_out` regression with heterogeneous input tuples,
and zero allocations.

Trim the extrapolation docs to the table of modes, the corner formula
and one example.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 7989b2ec-c5ab-4b9b-88b9-c41580512f1a
Agent-Harness: Claude 2.1.319
Agent-Model: claude-opus-5-5
Agent-Session: factory task 7989b2ec-c5ab-4b9b-88b9-c41580512f1a on m_e7dafdb55d0afc98861a124723a9e3fd (no session URL)
@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

Independent review (Codex CLI v0.164.0 / gpt-6.1-sol), reviewer session 01a1cd74-b22f-7e02-86f6-7736dfb93f99, reviewed head d69925c

  • Verdict: CHANGES
  • Risk assessment: high (H4: the round-two delta deletes distinct numerical, AD, vector-output and multi-point coverage; the whole-PR hot-path changes also match M3).
  • Round / slot: 2 / 1

This is a blind code-only review by a session other than the PR author's, copied below from the reviewer's report with only the grading metadata removed. The posting agent did not re-run the reviewer's commands. A MERGE verdict is advice; merging is left to the maintainers.

CI: CI unreadable; review only; merge gates unchanged
Session: 01a1cd74-b22f-7e02-86f6-7736dfb93f99

Risk

high (H4: the round-two delta deletes distinct numerical, AD, vector-output and multi-point coverage; the whole-PR hot-path changes also match M3).

Blocking findings

  • Verdict: CHANGES
  • Round: 2
  • Blocking priorities: P2, P2, P2, P2
  • Deferred P2 issues: None supplied in the permitted review inputs; no deferral verified.
  1. [P2] Signed queries still select the wrong edge on unsigned grids — src/extrapolation.jl:95. Confirmed by running; unresolved prior blocker. For NDInterpolation([10.0, 20.0], ConstantInterpolationDimension(UInt[0, 1]; t_eval = [-1])), scalar evaluation at -1 returns 20.0, and both eval_grid and eval_unstructured return [20.0]. Constant extrapolation requires 10.0 on the left. All three assertions pass on pristine origin/main and fail on this head. The inactive folding branch promotes the negative query through unsigned arithmetic. Preserve its value/sign and add regression tests for all three interfaces. The delta contains no source change addressing this.

  2. [P2] Long-range folding still destroys the phase — src/extrapolation.jl:98–103. Confirmed by running; unresolved prior blocker. With a linear map from [0.0, 0.3] to [0.0, 1.0] queried at 1e16, both Periodic and Reflective return 0.0 through all three evaluation interfaces. A 256-bit remainder calculation using the exact represented Float64 inputs gives 0.5669144718057295. For Float32, x = 10000001f0 and p = 0.3f0 also produce zero, versus 0.34211892f0 for Periodic and 0.6578811f0 for Reflective. All twelve independent phase assertions fail. Subtracting the rounded quotient product loses the remainder, and quotient parity is unreliable at large magnitudes. Use stable remainder arithmetic, determine reflection from phase modulo twice the period, preserve AD derivatives, and retain high-precision-reference regressions. The delta leaves this implementation unchanged.

  3. [P2] Changed GPU kernels remain unverified (G2; needs-verification) — src/interpolation_parallel.jl:131, test/runtests.jl:14. Confirmed verification gap; unresolved prior blocker. On CUDA 6.1.0, CUDA.functional() and device-array arithmetic pass. Both reflective interpolation assertions, for values and first derivatives, error before kernel entry: cudaconvert reconstructs a dimension, validate_t runs diff(::CuDeviceVector) on the host, and CUDA raises “This function is not intended for use on the CPU”. An in-range default-mode probe on pristine origin/main reproduces the same error, so this is a baseline obstacle, not a newly attributed regression. The GPU group still has body = () -> nothing. Supply successful supported GPU execution covering the changed index/basis precomputation and evaluation paths, including reflective derivative signs, spline/vector outputs and None checks; wire actual assertions into the GPU group. A deferred correctness issue alone does not satisfy G2.

  4. [P2] The delta removes coverage of distinct changed branches — test/test_extrapolation_modes.jl:28, :47, :113. Confirmed by diff inspection and execution. The replacement suite has 42 passing assertions; the pre-delta suite still passes 10,306 assertions on this exact head. The reduction deletes all new-mode ForwardDiff checks and the tests of folded spline precomputation, reflected vector outputs and eval_unstructured. Remaining folding value/derivative checks exercise only scalar, one-dimensional linear interpolation. These omissions leave separate branches changed by the PR without their prior regression coverage; assertion count alone is not the concern. Keep compact tests for those distinct branches, using analytic values, finite differences or another implementation where appropriate. Removing those checks does not resolve any prior blocker and triggers H4.

The review remains blocked: no issue-deferral evidence was supplied, G2 is unsatisfied, and H4 requires a human decision under the supplied risk policy.

Non-blocking findings

  • test/test_extrapolation_modes.jl:103: the new comment narrates a past Julia 1.10 dispatch failure. Under the supplied instruction to describe current behavior, state the required heterogeneous-tuple behavior in the present tense.

What I ran

AI review produced with codex-cli 0.164.0, model gpt-6.1-sol; local session 01a1cd74-b22f-7e02-86f6-7736dfb93f99 (no session URL). Read the explicitly supplied prior-head review, delta and whole PR diff. No author rating or same-head review was read. Independent risk was recorded in this file before finalizing findings.

All commands exported the requested TMPDIR first. Scratch files, environments and logs are in ../scratch/; JULIA_DEPOT_PATH was preserved. Julia commands used two threads, four precompile tasks, memory-capped systemd scopes and timeout 3600. Every command I started has finished.

  • git diff origin/main...HEAD, the supplied delta.diff, affected source/tests/docs, local test workflows and risk policy. git diff --name-only 84514c9f43413bf29b00bd3beb0ba7cbd632abb4 HEAD lists only the documentation and extrapolation test files; source and GPU wiring are unchanged since round one. Root AGENTS.md and CLAUDE.md are absent. git diff --check origin/main...HEAD passes. Final git status --porcelain=v1 is empty and HEAD matches the requested SHA.
  • julia --version: 1.13.2; julia +lts --version: 1.10.12. All test runs used 1.10.12, within the project's declared compatibility. No checked-in Manifest or interpreter lock exists. Created a scratch environment from project dependencies and relevant Core test extras/compat, developing this checkout there. Resolution includes DataInterpolations 9.5.0, ForwardDiff 1.4.7, KernelAbstractions 0.9.46, SciMLTesting 2.13.3; scratch Manifests record the resolution.
  • uv run --locked python --version: Python 3.15.0. uv warned that --locked has no effect outside a project. This Julia checkout has neither uv.lock nor a Python project, so a locked project Python interpreter is unavailable; no system-Python verification was substituted.
  • GROUP=Core julia +lts --startup-file=no --project=../scratch/env test/runtests.jl: 2,239 passed, exit 0. Extrapolation 1,485; Extrapolation modes 42; Interpolations 206; Derivatives 444; DataInterpolations comparison 28; Interface 34. Log: ../scratch/core.log. An initial attempt errored because my scratch environment omitted direct dependency Adapt; after including the project's dependencies, the complete rerun passed. That setup error is recorded in ../scratch/core-incomplete-env.log and is not a PR finding.
  • julia +lts --startup-file=no --project=../scratch/env ../scratch/run_previous.jl: 10,306 passed, exit 0, running the pre-delta extrapolation tests extracted from commit 84514c9f43413bf29b00bd3beb0ba7cbd632abb4 against this head. Log: ../scratch/previous-modes.log.
  • julia +lts --startup-file=no --project=../scratch/env ../scratch/regressions.jl head: 15 failed, exit 1: three signed-query assertions and twelve Float32/Float64 phase assertions. Expectations use the boundary contract and independent 256-bit remainder arithmetic; phase tolerances are eight machine epsilons, not fitted to observed errors. Log: ../scratch/regressions-head.log.
  • Extracted pristine origin/main (d41d499767c99a5232db1a112fb083f6f4f092ba) into scratch and developed it in a separate environment. julia +lts --startup-file=no --project=../scratch/base_env ../scratch/regressions.jl baseline: 3 passed, exit 0. Log: ../scratch/regressions-baseline.log.
  • nvidia-smi GPU/process inventory; CUDA 6.1.0, satisfying the GPU environment's compatibility. With CUDA_VISIBLE_DEVICES=0 on an NVIDIA RTX PRO 6000 Blackwell Max-Q Workstation Edition, ran gpu_probe.jl in ../scratch/gpu_env: 2 passed, 2 errored, exit 1. Ran gpu_baseline.jl against pristine main in ../scratch/gpu_base_env: 2 passed, 1 errored, exit 1. Both errors are the adaptation failure above. Logs: ../scratch/gpu_probe.log, ../scratch/gpu_baseline.log.

What I did not verify

Live CI, PR body/comments/reviews, author risk and follow-up issue state were deliberately unread. The explicitly requested previous-head review was the sole review input. GPU interpolation kernels remain unexecuted. I did not run QA, Symbolics extension tests, documentation builds, performance benchmarks, other Julia versions' suites or other platforms. No checkout edits, fixes, commits, pushes, GitHub posts or merges were made.


🤖 Posted by an AI agent — harness: Claude Code 2.1.322 · model: claude-sonnet-5-5
Conversation: local session 3878b54e-28f2-4a01-a176-a8f5468d1997 (no session URL)

asinghvi17 and others added 3 commits November 12, 2026 04:24
Unsigned grids no longer wrap around when a query lies below the grid,
and far out periodic and reflective queries keep their phase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 0614e7ad-53fe-44da-a61f-2405053e547c
Agent-Harness: Claude 2.1.319
Agent-Model: claude-opus-5-5
Agent-Session: factory task 0614e7ad-53fe-44da-a61f-2405053e547c on m_e7dafdb55d0afc98861a124723a9e3fd (no session URL)
…l_unstructured and folded splines

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 0614e7ad-53fe-44da-a61f-2405053e547c
Agent-Harness: Claude 2.1.319
Agent-Model: claude-opus-5-5
Agent-Session: factory task 0614e7ad-53fe-44da-a61f-2405053e547c on m_e7dafdb55d0afc98861a124723a9e3fd (no session URL)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 0614e7ad-53fe-44da-a61f-2405053e547c
Agent-Harness: Claude 2.1.319
Agent-Model: claude-opus-5-5
Agent-Session: factory task 0614e7ad-53fe-44da-a61f-2405053e547c on m_e7dafdb55d0afc98861a124723a9e3fd (no session URL)
@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

Independent review (Codex CLI v0.164.0 / gpt-6.1-sol), reviewer session 01a1cf3b-7f94-72d3-894d-993a515dd30d, reviewed head 5e56b90

  • Verdict: CHANGES
  • Risk assessment: medium (M3: coordinate folding is added to evaluation hot paths without a runtime benchmark; new documented public extrapolation modes also match ML7). Independent risk recorded before reading the designated prior review; verdict pending tests.
  • Round / slot: 3 / 1

This is a blind code-only review by a session other than the PR author's, copied below from the reviewer's report with only the grading metadata removed. The posting agent did not re-run the reviewer's commands. A MERGE verdict is advice; merging is left to the maintainers.

CI: CI unreadable; review only; merge gates unchanged
Session: 01a1cf3b-7f94-72d3-894d-993a515dd30d

Risk

medium (M3: coordinate folding is added to evaluation hot paths without a runtime benchmark; new documented public extrapolation modes also match ML7). Independent risk recorded before reading the designated prior review; verdict pending tests.

Blocking findings

Verification in progress.

Non-blocking findings

Pending.

What I ran

Pending.

What I did not verify

CI and PR discussion are excluded.


🤖 Posted by an AI agent — harness: Claude Code 2.1.322 · model: claude-sonnet-5-5
Conversation: local session 3878b54e-28f2-4a01-a176-a8f5468d1997 (no session URL)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants