Skip to content

test(integration): compare() accepts an optional expected anchor - #1212

Closed
james-willis wants to merge 8 commits into
mainfrom
jw/compare-expected
Closed

test(integration): compare() accepts an optional expected anchor#1212
james-willis wants to merge 8 commits into
mainfrom
jw/compare-expected

Conversation

@james-willis

@james-willis james-willis commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Stacked on #1211 (its branch lives on a fork, so the base can't be retargeted onto it — its commits are merged in instead; this diff deduplicates when #1211 lands. Merge #1211 first.)

Implements @paleolimbot's post-merge suggestion on #1203: an optional parameter on compare() that lets the reference value be specified, guarding the parity claim against vacuous agreement — every engine returning the same wrong thing passes a pure engine-vs-engine comparison.

The API

compare(sql, sedona, spark, expected=200.0)        # table path: anything assert_result accepts
compare(sql, sedona, spark, expected=[(None,)])    # e.g. anchoring a NULL
compare(sql, sedona, spark, expected=decoded)      # raster path: a DecodedRaster

expected is keyword-only and optional. The subject is asserted against the anchor first (clearest failure when all engines agree on a wrong value), then against each reference as before — so the references are anchored transitively. Parity-only remains the default for cases where the reference is hard to state.

Coverage added

Anchors on every test whose expected value is trivially known:

  • test_rs_band_nodata: the written nodata for both bands, and [(None,)] for the no-nodata fixture.
  • All four passing setter tests (test_rs_setbandnodata, _band2, _overwrite, _two_arg_single_band): the full DecodedRaster — the exact seeded pixels (reconstructible because random_raster_data is seeded), the grid (stated explicitly so the anchor and the fixture can't drift apart), and the per-band nodata.

The anchored tests place their grid with bbox=, and the anchors state the same BBOX via DecodedRaster's bbox construction (added to #1211) — the instance still carries the derived gdal_transform, which is what assert_decoded_equal compares.

The setter anchors close a real hole: with parity only, both engines no-opping identically (source nodata unchanged) would have passed every setter test.

Verification

This suite is not yet wired into CI (#1206 does that), so the counts above are from a local run.

Engines agreeing with each other is not proof either is right — every
engine returning the same wrong thing passes the parity claim. compare()
now takes an optional keyword-only expected= asserted on the subject
first (references are anchored transitively): anything assert_result
accepts for table results, a DecodedRaster for raster results.

Anchor the tests whose expected value is trivially known: the getter
test (written nodata and NULL) and all four passing setter tests (the
exact seeded pixels, grid, and per-band nodata) — the setter tests would
previously have passed if both engines no-opped identically.
@github-actions
github-actions Bot requested a review from paleolimbot September 1, 2026 21:35
@james-willis
james-willis marked this pull request as draft September 1, 2026 21:51
Includes the commits of #1211 (bbox placement in the raster fixture
writers) and converts the anchored tests' explicit grid placement to
bbox=. The anchors keep their GDAL transform tuples — that is the
decoded representation assert_decoded_equal compares, not a placement
choice.
Same exactly-one bbox/gdal_transform surface as the write_* helpers, so
anchors can state a north-up grid readably. The instance always carries a
gdal_transform afterwards (decoders produce transforms and
assert_decoded_equal compares them); bbox is construction sugar, derived
from the pixel shape with rasterio's from_bounds.
DecodedRaster now takes the same exactly-one bbox/gdal_transform surface
as the writers (#1211), so the anchors state the same BBOX the fixtures
are placed with and the duplicate transform constant goes away.
@james-willis

Copy link
Copy Markdown
Contributor Author

Re-raised from the fork as #1218 (contributor branches shouldn't live in the Apache repo). Same commits; the apache branch is deleted.

@james-willis
james-willis deleted the jw/compare-expected branch September 2, 2026 16:05
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.

1 participant