geotiff: canonical round-trip invariants module (#1986)#2007
Merged
Conversation
Adds xrspatial/geotiff/tests/test_round_trip_invariants.py with the first slice of the round-trip contract from issue #1986. Cases covered: * int single-band, no nodata: byte-equivalent for pixels and dtype. * float single-band, no nodata: byte-equivalent for pixels, including NaN-as-data positions. Asserts no synthetic GDAL_NODATA tag. * int single-band with declared nodata: documented drift -- reader promotes to float64 + NaN; valid pixels are byte-equal, sentinel survives in attrs['nodata']. * multiband chunky (2/3/4 bands, uint8): byte-equivalent for pixels, dtype, dims. * no-georef: semantic-equivalent. transform attr stays absent on read and through round-trip. * PixelIsPoint: byte-equivalent for raster_type attr and pixels. Defaults (PixelIsArea) leave raster_type absent. Each case asserts fixed-point convergence: a second write -> read cycle reproduces the first read exactly. Deferred to follow-up PRs (called out in the module docstring): * float with non-NaN declared nodata -- needs the masked / declared nodata split from issue #1988 to state the invariant cleanly. * planar multiband -- writer emits chunky only. * overviews / COG. * VRT. Per-incident round-trip files (test_metadata_round_trip_1484.py, test_int_coords_round_trip_hotfix_1962.py, etc.) stay as regression markers for their bug numbers.
…1986) Review follow-up for #2007. Tightens the round-trip contract: * _assert_fixed_point now compares values of canonical attrs (crs, transform, nodata, raster_type) when both sides of a write -> read cycle have the key. transform compares up to float precision; the others must match exactly. * TestIntSingleBandNoNodata, TestMultibandChunky: assert 'nodata' is absent on read and after round-trip. The reader must not invent a sentinel for int / uint8 rasters that never declared one. * TestNoGeorefSemantic: assert dtype on the source read so the array comparison cannot accidentally pass via cross-dtype broadcasting. * TestIntWithDeclaredNodata: drop redundant .ravel() on a boolean mask result (already 1D).
Contributor
Author
PR Review: geotiff: canonical round-trip invariants module (#1986)Test-only PR. Steps for algorithm correctness, backend dispatch, CUDA register pressure, and README feature matrix do not apply -- no production code changed, no new public API. Review focuses on test quality, the asserted invariants, and coverage gaps the module itself flags. BlockersNone. Suggestions
Nits
What looks good
Checklist
|
…1986) Review follow-up for #2007. The PixelIsArea default test asserted ``da.attrs.get('raster_type') is None``, which passes both when the key is absent and when it is present with value None. The canonical signal for "default raster type" is absence -- mirror the ``'nodata' not in attrs`` style used in the int and multiband cases so the contract is uniform across the module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First slice of issue #1986. Adds
xrspatial/geotiff/tests/test_round_trip_invariants.py-- one canonical module that enumerates the supported round-trip cases and pins the invariant per case.The existing per-incident round-trip files (
test_metadata_round_trip_1484.py,test_int_coords_round_trip_hotfix_1962.py,test_no_georef_writer_round_trip_1949.py,test_miniswhite_writer_roundtrip_1836.py) stay as regression markers for their bug numbers. This module is the canonical contract going forward.Cases covered
Each case also asserts fixed-point convergence: a second
write -> readcycle reproduces the first read exactly (pixels, dtype, dims, attrs key set).Deferred to follow-up PRs
Called out in the module docstring:
Test plan
pytest xrspatial/geotiff/tests/test_round_trip_invariants.py -v-- 14 passedCloses part of #1986.