Record why the raster payload omits the density overlay#295
Conversation
Review on #284: dropping the point-sample overlay on the raster path left no trace in the spec, which contradicts the §28 rule that no decimation decision is silent. The oversized branch already records overlay_omitted = "rows_exceed_u32"; this adds "static_raster" for the new case, guarded so it cannot mask the more fundamental u32 reason when both apply. Tests pin the field on the raster payload and its absence on the wire payload, so the raster-only flag can never leak to the client. Also tighten the import guard: it now measures modules imported after NumPy, so NumPy's own tree is never attributed to xy, and it checks for xml.sax.saxutils directly instead of only the urllib/ssl/email fallout that import happens to drag in today. A future slimmer saxutils would otherwise let the removed import creep back without failing the test named for it. overlay_omitted is written only into the private raster spec, which no renderer reads: all 72 artifact hashes across 12 figure configurations are unchanged. Full suite 2283 passed.
📝 WalkthroughWalkthroughRaster density payloads now record why overlays are omitted, with tests and documentation covering raster versus wire behavior. The SVG import regression test now checks only modules newly imported by ChangesDensity overlay omission contract
SVG import isolation guard
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_raster_density_overlay.py (1)
44-50: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd coverage for
rows_exceed_u32precedence.The new test covers normal raster exports, but not the documented case where both conditions apply. Add a regression case confirming that
overlay_omittedremains"rows_exceed_u32"rather than being overwritten with"static_raster".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_raster_density_overlay.py` around lines 44 - 50, Add a regression test alongside test_raster_payload_omits_the_overlay that configures a raster payload with both rows exceeding u32 and a static raster overlay, then assert density["overlay_omitted"] is "rows_exceed_u32". Preserve the existing normal-overlay omission assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_raster_density_overlay.py`:
- Around line 44-50: Add a regression test alongside
test_raster_payload_omits_the_overlay that configures a raster payload with both
rows exceeding u32 and a static raster overlay, then assert
density["overlay_omitted"] is "rows_exceed_u32". Preserve the existing
normal-overlay omission assertion.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e68a7b9e-801f-444a-96d7-4689117394b8
📒 Files selected for processing (4)
python/xy/_payload.pyspec/api/export.mdtests/test_raster_density_overlay.pytests/test_svg_escape.py
Merging this PR will not alter performance
Comparing Footnotes
|
Follow-up to #284, addressing its review.
The finding
#284 made the raster exporters skip the density point-sample overlay, because
_raster._emit_gridnever readsdensity["sample"]. But it dropped thatrepresentation without recording anything, which contradicts a stated invariant:
The neighbouring branch already honours this — it sets
density["overlay_omitted"] = "rows_exceed_u32"when row ids exceed u32. The newraster case had no equivalent, so a raster payload dump showed an absent
samplewith no explanation.
What changed
density["overlay_omitted"] = "static_raster"on the raster path, guarded withif "overlay_omitted" not in densityso it cannot mask the more fundamentalrows_exceed_u32reason when a trace hits both.Tests pin both halves: the field is present on the raster payload, and absent
from
build_payload, so the raster-only flag can never leak to the client.Also tightens the import guard added in #284:
xml.sax.saxutilsjoins the forbidden set directly, rather than the guard relyingon the urllib/ssl/email tree that import happens to drag in today — a future
slimmer
saxutilswould otherwise let the removed import creep back withoutfailing the test named for it
Verification
overlay_omittedis written only into the private raster spec, which no rendererreads, so this is observably inert:
and wire spec, across 12 figure configurations (density, direct, f32, clipped,
continuous colour, NaN-injected, log axes, categorical at 2.2M, line, and one
with
& < > " 'plus non-BMP characters in the title)ruff checkandruff format --checkcleanSpec updated in
spec/api/export.mdalongside the code.Summary by CodeRabbit
Bug Fixes
Documentation
Tests