Skip to content

geotiff tests: consolidate input-validation cluster#2461

Merged
brendancol merged 4 commits into
mainfrom
worktree-agent-ab51e0e9dc335ea9d
May 26, 2026
Merged

geotiff tests: consolidate input-validation cluster#2461
brendancol merged 4 commits into
mainfrom
worktree-agent-ab51e0e9dc335ea9d

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #2430. Cluster 6 of the long-tail GeoTIFF test consolidation epic (#2424).

Summary

Fold nine top-level files into a new xrspatial/geotiff/tests/unit/test_input_validation.py:

  • test_degenerate_pixel_size_2214.py
  • test_geotiff_band_bool_rejection_1786.py
  • test_geotiff_band_type_rejection_1910.py
  • test_pixel_array_count_cap_1901.py
  • test_size_param_validation_1752.py
  • test_strip_zero_dims_2053.py
  • test_tile_size_multiple_of_16_1767.py
  • test_validate_3d_non_band_trailing_dim_2240.py
  • test_window_out_of_bounds_1634.py

The new file is organised by validation axis:

  1. band type / bool rejection -- band must be a non-negative int; bool / np.bool_ raise ValueError, float / str raise TypeError, across read_to_array, open_geotiff, read_geotiff_dask, read_geotiff_gpu, and read_vrt.
  2. Size-parameter validation -- tile_size and read_geotiff_dask chunks must be positive, and tile_size must be a multiple of 16 when tiled=True.
  3. Source-dimension validation -- zero / negative ImageWidth / ImageLength / SamplesPerPixel rejected on stripped and tiled read paths, local and HTTP, plus pixel-array count caps against IFD geometry.
  4. 3D writer-dim validation -- (y, x, <non-band>) DataArray inputs rejected rather than silently written band-last.
  5. Window-bounds validation -- an out-of-bounds window raises a clear ValueError on the eager and dask paths.
  6. Degenerate pixel-size fail-closed -- a 1xN / Nx1 write with no transform and no opt-in raises rather than borrowing the other axis's pixel size.

One intentional dedup: the bool file's test_read_to_array_band_one_still_works is the same test as the type file's test_read_to_array_band_int_still_works (both read band 1), so only one survives. That accounts for 145 collected here vs 146 across the nine originals.

The reader.windowed release-gate row in docs/source/reference/release_gate_geotiff.rst cited test_window_out_of_bounds_1634.py; it now cites the consolidated file so the checklist-parity gate stays green.

Audit

xrspatial/geotiff/tests/CLUSTER_AUDIT_INPUT_VALIDATION.md maps every old file::test to its new file::test_id. The audit file is deleted on a final commit on this branch before merge.

Verification

  • pytest xrspatial/geotiff/tests/unit/test_input_validation.py -v: 145 passed.
  • pytest xrspatial/geotiff/tests/ -q: 5814 passed, 68 skipped, 2 xfailed.
  • find xrspatial/geotiff/tests -name 'test_*.py' | wc -l: 236 (was 244; -9 deleted +1 added = -8).

Test plan

  • New unit/test_input_validation.py passes on this checkout.
  • Full xrspatial/geotiff/tests/ suite passes.
  • Release-gate checklist-parity test passes.

Fold nine top-level input-validation test files into a new
xrspatial/geotiff/tests/unit/test_input_validation.py, organised by
validation axis: band type/bool, size params, source dimensions, 3D
writer dims, window bounds, and degenerate pixel size.

Update the reader.windowed release-gate row to cite the new file so
the checklist-parity gate stays green.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 26, 2026
Copy link
Copy Markdown
Contributor Author

@brendancol brendancol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: geotiff tests: consolidate input-validation cluster

Tests-only consolidation. Nine top-level input-validation files fold into unit/test_input_validation.py, grouped into 22 classes across six validation axes. No xrspatial/geotiff source changes. I read all nine originals and the new file, ran the suite, and checked parity.

Blockers (must fix before merge)

None.

Suggestions (should fix, not blocking)

None.

Nits (optional improvements)

  • A couple of TestBandTypeRejection cases are really bool-rejection or positive-path checks (test_read_to_array_band_bool_still_rejected, test_read_to_array_band_zero_still_works), not type-rejection. This follows how the originals were split (the type file owned the positive still-works cases), so it is defensible. A reader skimming by class name might expect those elsewhere. Not worth the churn to move them.

What looks good

  • The 145-vs-146 count delta is intentional and documented: test_read_to_array_band_one_still_works is the same test as test_read_to_array_band_int_still_works (both read band 1), so one drops. Called out in the PR body and the audit file.
  • The behavior-bearing helpers carry over unchanged: the IFD byte builders (_build_classic_tiff, _short_bytes, _long_bytes), the tag-patch helpers (_find_ifd_entry_offset, _patch_inline_long), the _StaticBytesHTTPSource stub, and the MAX_PIXEL_ARRAY_COUNT monkeypatch with its try/finally restore.
  • The per-file _gpu_only markers are replaced with the shared requires_gpu from _helpers/markers.py, same cupy.cuda.is_available() semantics.
  • The release-gate checklist row that cited the deleted test_window_out_of_bounds_1634.py now points at the consolidated file, so the checklist-parity gate stays green. Easy to miss.
  • isort and flake8 both pass (lines under 100).

Checklist

  • N/A algorithm vs reference (tests-only)
  • All four read backends still covered (numpy eager, dask, gpu-gated, vrt)
  • NaN handling unchanged (no logic touched)
  • Edge cases preserved (zero/negative dims, out-of-bounds windows, degenerate 1xN/Nx1)
  • N/A dask chunk boundaries
  • N/A premature materialization
  • N/A benchmark
  • N/A README feature matrix (no new public API)
  • Docstrings: module-level and per-class present

@brendancol brendancol merged commit a4b9c16 into main May 26, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidation cluster 6: input validation (long-tail epic #2424)

1 participant