fix: Make the predictor fixtures test what their names say - #76
Merged
Merged
Conversation
Follow-up to #74, which made write_cog actually write the predictor: - uint16_1band_lzw_block128_predictor2: its arange data never carried from the low byte into the high byte within a tile row, so a reader that undoes predictor 2 byte by byte, or without wrapping, still read it correctly. Each row is now a triangle wave stepping by 1000 per pixel. The fixture is also 256x256 with the 128x128 tiles its name says, instead of 128x128 with 64x64 tiles. - uint16_1band_scale_offset: drop the predictor, which #74 turned on, so a reader without predictor support doesn't fail this fixture's scale/offset test. The file is back to its pre-#74 bytes. Also fix its docstrings, which said LZW and 512x512. - Add uint8_rgb_deflate_block64_predictor2: every predictor fixture was single band, so a reader that differences adjacent samples instead of adjacent pixels passed them all. - Add float32_1band_deflate_block64_predictor3: write_cog can write predictor 3 now, but no fixture had it. tests/test_predictor.py now checks every generated fixture: it carries a predictor exactly when its name says so, ignoring GDAL's mask IFDs, which never have one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kylebarron
force-pushed
the
fix/predictor-fixtures
branch
from
October 1, 2026 22:11
a50ca68 to
f37ed41
Compare
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.
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
Follow-up to #74. That PR made
write_cogactually write the predictor, but reviewing it showed the predictor fixtures still miss common reader bugs. This PR doesn't touchwrite_cog. It's rebased onto #75, and its fixtures regenerate byte for byte with #75'swrite_cog.Changes
uint16_1band_lzw_block128_predictor2gets new data and tiles.np.arangedata steps by 1 per pixel, so within a tile row the low byte never carries into the high byte. A reader that undoes predictor 2 byte by byte still decodes it correctly, and so does one that adds without wrapping.uint16_1band_scale_offsetdropspredictor=2. fix: Write the predictor into COGs from write_cog #74 turned that predictor on, so a reader without predictor support started failing what looks like a scale/offset test. The.tifand_info.mdare back to their exact pre-fix: Write the predictor into COGs from write_cog #74 bytes. Its docstrings no longer say LZW and 512×512.uint8_rgb_deflate_block64_predictor2. Every predictor fixture was single band, so a reader that differences adjacent samples instead of adjacent pixels passed them all. Each band changes differently along the rows.float32_1band_deflate_block64_predictor3.write_cogcan write predictor 3 since fix: Write the predictor into COGs from write_cog #74, but no fixture had it. It uses the samenp.linspacedata asfloat32_1band_lerc_block32.Simulated buggy readers
I re-applied predictor 2 to every tile row as rasterio reads it, then decoded it with simulated buggy readers. Each cell counts the tiles, across both levels, that the reader decodes correctly. The buggy readers should get none.
uint16_…_predictor2onmainuint16_…_predictor2hereuint8_rgb_…_predictor2Tests
tests/test_predictor.pynow checks every generated fixture instead of four named ones. A fixture must carry a predictor on every IFD exactly when its name sayspredictorN. GDAL's mask IFDs are skipped because GDAL never writes a predictor on them: a masked predictor 2 COG has predictors[2, 1, 2, 1]. Onmainthe test fails foruint16_1band_scale_offset.pixi run checkandpixi run testpass. All four new or changed files passrio cogeo validate --strict.Downstream
uint16_1band_lzw_block128_predictor2changes size and tiling. Tests that compare against regenerated.npytiles pick that up automatically. Anything that hard-codes its size or tile count needs an update.uint16_1band_scale_offsetno longer needs predictor support.Merging with #73
uint16_1band_lzw_block128_predictor2_big_endianis rewritten from the uint16 fixture here. Whichever PR lands second needs apixi run generate. After that, the big endian copy also has the 128×128 tiles its name says.float32_1band_deflate_block64_predictor3instead of a temporary source.🤖 Written by Claude Code