Share the nnn=1 guard between both interpolation entry points; delete the dead RBF surface#446
Conversation
… the dead RBF surface Fixes #443, #428. #443: `interpolation_matrix(nnn=1, order=1)` silently returned a nearest-neighbour operator where `rbf_interpolator_local` raised. The caller asked for a linear-exact operator and got a constants-only one with nothing recording the downgrade. Cause: `_local_stencil` early-returns for `nnn == 1` before any `order` handling, and the guard sat in `rbf_interpolator_local_from_kdtree` only. Sharing a core is not the same as sharing its guards -- the PR that added `interpolation_matrix` claimed the two paths "cannot drift apart", and this is precisely how they did. The guard now lives in `_local_stencil`, so both entry points inherit it, and a test exercises both. Two smaller things at the same site: the stencil-too-large `RuntimeError` named `rbf_interpolator_local_from_kdtree`, a function the caller never invoked -- it now reports the requested stencil size and the tree size. The degenerate-fallback warning used `stacklevel=3`, tuned for the value path's depth; the two entry points sit at different depths, so it is now 2, the deepest frame correct for both. #428: removed the dead RBF surface. - `MeshVariable.rbf_interpolate(meth=, rubbish=)` -- neither was ever read; `meth` was documented as "reserved", which Charter S5 rules out. Removing `meth` also fixes `tests/test_0505_rbf_swarm_mesh.py`, which passed its `nnn` positionally into `meth` and so silently ran every case at the default stencil -- including the case that believed it was testing the raw nearest-neighbour branch. No other caller passes a second positional. - `SwarmVariable._rbf_reduce_to_meshVar`, `Swarm._get_map`, `Swarm._nnmapdict` and the `_nn_proxy` flag that gated them. Zero callers; deletion of the trio is the disposition already recorded for SWARM-23 in SWARM_MODERNIZATION_DESIGN_2026-07.md, which notes `_get_map` caches particle indices against a stale key and is a live trap if revived. level_1 551 passed, level_2 319 passed, np=2 parallel 4 passed, style gate clean. 105 lines deleted, 65 added. Underworld development team with AI support from Claude Code
Adversarial reviewThe deletions are broader than "dead code" implies
Same for The #443 fix is narrower than the class of bugMoving one guard into Worth stating plainly: What the tests do and do not coverThe new guard test asserts both entry points raise, and that The error-message test pins a string ( What I did not do
What holds up
|
|
Checked the one open question from the review: |
|
Correction to the comment above: the file is |
Fixes #443, #428.
#443 — the two paths drifted exactly where I said they could not
interpolation_matrix(nnn=1, order=1)silently returned a nearest-neighbour operator where the value path raised:The caller asked for a linear-exact operator and got a constants-only one, with nothing recording the downgrade.
Cause:
_local_stencilearly-returns fornnn == 1before anyorderhandling, and the guard sat inrbf_interpolator_local_from_kdtreealone. Sharing a core is not the same as sharing its guards. #430's body claimed the two paths "cannot drift apart"; this is how they did.The guard moves into
_local_stencil, so both entry points inherit it. Verified on both, withnnn=1, order=0still legal on both.Two smaller things at the same site:
Error in rbf_interpolator_local_from_kdtree - a nearest neighbour wasn't found, naming a function the caller never invoked. It now reports the requested stencil size and the tree size:Cannot build a 20-point stencil: the kd-tree holds 5 point(s)...stacklevel=3, tuned for the value path's depth. The two entry points sit at different depths below_local_stencil, so it is now2— the deepest frame correct for both.#428 — dead RBF surface removed
MeshVariable.rbf_interpolate(meth=, rubbish=). Neither was ever read.methwas documented as "reserved, currently unused", which Charter §5 rules out.Removing
methalso fixes a latent test bug:tests/test_0505_rbf_swarm_mesh.pycallsvar.rbf_interpolate(rx, nnn, p), so itsnnnlanded inmethand was discarded — every parametrised case actually ran at the default stencil, including the(2, 1, 2)case that believed it was testing the raw nearest-neighbour branch. Withmethgone the positional argument means what the test always intended, and the file passes unchanged.Checked: no other caller passes a second positional argument.
_rbf_reduce_to_meshVar,Swarm._get_map,Swarm._nnmapdict,_nn_proxy. Zero callers. Deleting the trio is the disposition already recorded for SWARM-23 indesign/SWARM_MODERNIZATION_DESIGN_2026-07.md, which notes_get_mapcaches particle indices against a stale key and is a live trap if anything revives it._nn_proxyexisted only to gate a branch inside the dead method and was plumbed out toSwarm.add_variable.Regression
tier_a/tier_b: 551 passed, 0 failedtier_a/tier_b: 319 passed, 0 failed105 lines deleted, 65 added.
Underworld development team with AI support from Claude Code