Skip to content

Test: cover GPU writer overview_resampling='mode' and compression_level= #1740

@brendancol

Description

@brendancol

Coverage gap

write_geotiff_gpu and to_geotiff(gpu=True) accept seven overview_resampling modes: mean, nearest, min, max, median, mode, cubic. Six have direct end-to-end coverage:

  • mean: test_cog_overview_nodata_1613, test_features
  • nearest: test_features, test_cog::test_gpu_overview_resampling_nearest
  • min / max / median: test_overview_resampling_min_max_median_2026_05_11
  • cubic: test_signature_parity_1631::test_write_geotiff_gpu_cubic_overview_round_trip

mode is the odd one out. The branch in _block_reduce_2d_gpu (xrspatial/geotiff/_gpu_decode.py:3051-3056) and the matching write_geotiff_gpu(cog=True, overview_resampling='mode') / to_geotiff(gpu=True, ..., overview_resampling='mode') paths have no tests. test_mode_overview_perf.py exercises the CPU _block_reduce_2d helper, not the GPU one.

If someone dropped the mode dispatch from _block_reduce_2d_gpu, the function would fall through to the mean reshape branch and emit wrong overview pixels for integer rasters. Nothing in the suite would catch it.

Secondary gap

write_geotiff_gpu(compression_level=...) is documented as "Accepted for API compatibility but currently ignored -- nvCOMP does not expose level control". to_geotiff threads the kwarg through to write_geotiff_gpu unchanged. No test pins the contract: the kwarg has to be accepted for every codec, out-of-range values should not raise on the GPU writer (the CPU writer rejects compression_level=999 with ValueError), and the file should still round-trip. If someone wired the GPU writer up to the same range validator as the CPU writer, every to_geotiff(gpu=True, compression_level=X) caller would break silently for in-range levels and noisily for out-of-range ones.

Severity

Cat 4 (parameter coverage) HIGH for the mode branch: documented codec on a shipped public API with no test. MEDIUM for the compression_level accepted-but-ignored contract: a regression would change the GPU writer's behaviour against its docstring.

Fix

Add test_gpu_writer_overview_mode_and_compression_level.py covering:

  • _block_reduce_2d_gpu(method='mode') direct call, matching CPU reference output bit-for-bit.
  • write_geotiff_gpu(cog=True, overview_resampling='mode') end-to-end round trip on an integer raster.
  • to_geotiff(gpu=True, cog=True, overview_resampling='mode') dispatcher thread-through.
  • GPU-vs-CPU writer pixel parity for overview_resampling='mode' on integer input.
  • write_geotiff_gpu(compression_level=N) accepted-but-ignored for an in-range and out-of-range level on zstd and deflate.
  • to_geotiff(gpu=True, compression_level=N) dispatcher thread-through.

Filed by the test-coverage sweep on 2026-05-12. Source unchanged; test-only fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions