Repository navigation
fix(phs): ship PHS as experimental and reject inputs it cannot evaluate - #222
Conversation
PHS moves out of the main exports into a new `FastInterpolations.Experimental` submodule (not covered by SemVer; README and docs say so). Inputs the implementation cannot evaluate correctly now raise an error instead of returning wrong values. The evaluator and the defaults are unchanged. - New src/phs/phs_validate.jl with the gates, called from the constructor and the scalar/batch entry points before any pool buffer is acquired: real float grids and data only; uniform axes (ranges as is, vectors up to rounding); stencil_size ≥ 3 in 1-D/2-D (2 for N ≥ 3) and a stencil whose per-axis extent fits every axis; blend_factor finite and covering cell centres (rejects the 4-D default 1.0, which evaluated to 0.0 there); NoExtrap, FillExtrap or InBounds only; derivatives up to total order 2; log_reference with second derivatives limited to a blend candidate box of 27 nodes (the kernel's fixed buffer, which overflowed with a BoundsError before). - A call-time `extrap` override is validated like the other interpolants (only InBounds() passes) instead of being silently ignored. - Batch queries check the domain like scalar queries (NoExtrap → DomainError). - Docs and README mark PHS experimental; scripts and the CI benchmark load it from `Experimental`. - Tests: new test_phs_gates.jl; pins §O2 ×4 and §R4 promoted.
FastInterpolations.jl Benchmarks
All benchmarks (71 total, click to expand)
|
| Benchmark | Current | Previous | Imm. Ratio | Grad. Ratio | Tier |
|---|---|---|---|---|---|
13_nd_oneshot_gridquery/bilinear_2d_sort_rand |
10068.48 ns |
8824.3 ns |
1.141 |
1.08 |
immediate |
7_cubic_vec/scalar_query |
9.71 ns |
8.5 ns |
1.141 |
0.882 |
immediate |
Thresholds: immediate > 1.1x (vs latest master), gradual > 1.1x (vs sliding window)
Runner:
znver3|4c— AMD EPYC 7763 64-Core Processor, julia 1.13.1. Times are min-merged and compared only against this same machine's history.
This comment was automatically generated by Benchmark workflow.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #222 +/- ##
==========================================
+ Coverage 96.29% 96.31% +0.01%
==========================================
Files 172 173 +1
Lines 15484 15560 +76
==========================================
+ Hits 14910 14986 +76
Misses 574 574
🚀 New features to boost your workflow:
|
|
Hi @twilsonco, I moved |
|
That sounds like a good move. Thanks! |
|
@twilsonco Thank you again for your patience and great contribution for this new feature! |
Follow-up to #136 and #209.
Summary
Problem: PHS (merged in #136, not yet released) accepted inputs it cannot evaluate correctly and returned wrong values without any error, and it was exported as public API although parts of it are still being reworked.
Fix: PHS moves to a new
FastInterpolations.Experimentalsubmodule (outside SemVer), and inputs it cannot evaluate correctly now raise an error. The evaluator and the defaults are unchanged.ArgumentErrorArgumentErrorblend_factorleaving cell centres uncovered (incl. the 4-D default)ArgumentErrorArgumentErrorextrap=overrideInBounds(), as for the other interpolantsArgumentErrorlog_reference+ 2nd derivative with a wide blend (e.g. the one-shot default 2.0 in 3-D)BoundsError(out-of-bounds write without bounds checks)ArgumentErrorDomainError, like scalar queriesInexactError,MethodError); unit grids failed inside the buildArgumentErrorat constructionUsage
This adds the package's first
Experimentalsubmodule: its features are usable but outside SemVer, so they may change in any release. Users opt in explicitly; graduating a feature later only adds an export to the main module, and theExperimentalnames keep working.Changes
src/experimental.jl: new submodule re-exportingphs_interp,phs_interp!,PHSInterpolantND; removed from the main exports.src/phs/phs_validate.jl: the input gates;phs_interpolant.jlcalls them in the constructor and at the scalar/batch entry, before any pool buffer is acquired.Experimental(the blend study no longer runsblend_factor = 0.5, now rejected in 3-D); the CI benchmark callsFastInterpolations.phs_interp, which works on both master and this branch.Not covered
stencil_size,blend_factor): follow-up PRs.gradient/hessian,GriddedQuerywith N ≥ 2: still unsupported, tracked as@test_brokenpins.Tests
test/test_phs_gates.jl(its rejection checks fail on master);§O2×4 and§R4pins promoted intest/test_phs_broken_pins.jl.