Skip to content

baselines: independent IDW + NN reference module (scipy optional, #107) - #132

Merged
marzukia merged 2 commits into
mainfrom
pi-bg/20261015-233432-1975030
Oct 16, 2026
Merged

marzukia merged 2 commits into
mainfrom
pi-bg/20261015-233432-1975030

Conversation

@monkytheluffy

Copy link
Copy Markdown
Collaborator

Scope — issue #107 (B-10 repo side): independent IDW + nearest-neighbour baselines

New ppgrid/baselines.py: idw(points, values, query, power=2.0, k=8, min_neighbours="k") and nearest(points, query, values=None) — exact k-NN via scipy cKDTree, blocked 100k-row queries, zero runtime dependency on ppgrid.pipeline/pullpush (the single bridge is domain_from_pipeline, attribute reads only).

  • scipy is a new [baselines] optional extra — core install and core lock unchanged (verified: uv sync --dry-run without extras uninstalls scipy); scipy tests gated pytest.importorskip
  • Config-driven scale: bench/config/baselines.json (workload + limits), strict schema. v1 default = claimed regime 20M/1M/<10min/<32GB flagged needs_andryo_confirmation: true — limits are reported, never enforced
  • BaselineResult carries the exact search config (power/k/policy/k_used/scipy version/CRS) + measured wall & peak RSS vs limits; methods() renders a pasteable paper methods paragraph
  • ppgrid.__all__ unchanged; import via from ppgrid.baselines import ...
  • +19 tests (tests/test_baselines.py): hand-computed IDW closed forms (p=2, p=1), k=1↔nearest, zero-distance coincident, policy matrix, blocked-vs-direct, NN-vs-brute-force, coverage mask byte-equal vs pullpush.box_count, domain vs a real Melbourne run, 100k/10k sanity scale with 120s CI wall guard

Gates (re-run by the reviewer, not worker-claimed)

  • uv run pytest -x -q → 569 passed, 2 skipped (pre-existing macOS-only skips)
  • anchor gate bench/check_anchors.py → PASS, byte-identical (melb10 + melb500, cinterp)
  • ruff check . + ruff format --check . → clean; uv lock --check → exit 0

Review

Adversarial review (owner lens: connascence, bugs, fragility, DRY): PASS — no blockers, no majors. 7 minors recorded below, accepted as-is for this PR (candidates for the next tidy wave):

  1. CHANGELOG "Tests: +12" miscount → fixed on branch (tip now d9e2647)
  2. grid_query docstring: "y increasing with row" is true of internal arrays only; the published GeoTIFF is north-first (row-flipped) — consumer comparing to a rasterio read must flip or map by (x,y)
  3. claimed-regime defaults exist twice (dataclass fields + _DEFAULTS dict) — can silently diverge
  4. domain_from_pipeline re-derives x0/nx/ny instead of reading p.x0/... (deliberate: works pre-grid(); regression-guarded, but a grid-rule change must touch both)
  5. coincident-point docstring: the mean is over the k-NN returned subset, not all coincident points
  6. _peak_rss_mib() sampled twice per result (stored ≥ flag value; harmless, peak is monotonic)
  7. bench CLI overrides bypass from_dict strict validation (named ValueError surfaces later; acceptable)

Worker: pi-bg/20261015-233432-1975030 (5bb9ffa + d9e2647). Reviewer: pi-bg/20261016-004811-913082. Verdict: ~/.pi-bg-art/review-107-20261015-233432-1975030.md.

monkytheluffy added 2 commits October 16, 2026 11:45
- ppgrid/baselines.py: idw() + nearest() on exact k-NN (scipy cKDTree,
  blocked query), independent of ppgrid.pipeline; BaselineResult carries
  the full search config (power/k/neighbour policy/search method/scipy
  version) + measured wall/RSS vs configured limits, with methods()
  rendering a paper methods-section paragraph
- BaselineConfig + load_config: config-driven scale (workload + wall/RSS
  limits) from bench/config/baselines.json; v1 default = claimed regime
  (20M pts / 1M queries / <10 min / <32 GB) flagged
  needs_andryo_confirmation=true (a claim, not a threshold)
- domain_from_pipeline(): identical domain for a finished run (same
  points/CRS/res/grid/box-count coverage mask, seeded holdout; mask
  independently verified against pullpush.box_count); synthetic_workload
  + bench/baselines_bench.py harness
- scipy as [baselines] optional extra (core install unchanged); scipy
  tests gated pytest.importorskip; +19 tests (closed-form IDW, NN vs
  brute force 10k, policy matrix, config validation, domain vs real run,
  100k/10k sanity scale)
@marzukia
marzukia merged commit df2e715 into main Oct 16, 2026
11 checks passed
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