The geotiff writer test suite has gaps. This issue tracks adding tests for them. No source changes — test coverage only.
Findings from a recent audit of xrspatial/geotiff/_writer.py:
T-5: dtype x compression matrix. tests/test_writer.py covers a handful of dtype/codec combinations. A parametrized round-trip test over [uint8, uint16, uint32, int16, int32, int64, float32, float64] x [none, deflate, lzw, zstd, lz4] would catch dtype-specific encode/decode bugs. Unsupported combos (JPEG only handles uint8, etc.) get skipped explicitly.
T-6: NaN vs sentinel nodata. Nothing verifies the contract that to_geotiff(arr, path, nodata=np.nan) round-trips NaN positions, that nodata=-9999.0 writes the sentinel on disk but reads back as NaN, or the int-sentinel equivalent for uint8.
T-7: COG validity. The writer has a cog=True mode but no test confirms the output passes a third-party COG check (overview list, GDAL LAYOUT=COG tag). Use rasterio when present, skip otherwise.
T-9: write-to-readonly path. No test confirms that writing to a non-writable directory raises a clean OSError/PermissionError rather than a confusing deep-stack failure.
T-10: planar config 2 round-trip. Not applicable on the write side. _writer.py doesn't emit PlanarConfiguration=2 (only the reader supports it). Dropped from this issue; could be tracked separately as a writer feature.
Acceptance: tests land in xrspatial/geotiff/tests/test_writer.py (or a new test_writer_matrix.py) and pass on CI. Rasterio-dependent COG check skips when rasterio is missing.
The geotiff writer test suite has gaps. This issue tracks adding tests for them. No source changes — test coverage only.
Findings from a recent audit of
xrspatial/geotiff/_writer.py:T-5: dtype x compression matrix.
tests/test_writer.pycovers a handful of dtype/codec combinations. A parametrized round-trip test over[uint8, uint16, uint32, int16, int32, int64, float32, float64]x[none, deflate, lzw, zstd, lz4]would catch dtype-specific encode/decode bugs. Unsupported combos (JPEG only handles uint8, etc.) get skipped explicitly.T-6: NaN vs sentinel nodata. Nothing verifies the contract that
to_geotiff(arr, path, nodata=np.nan)round-trips NaN positions, thatnodata=-9999.0writes the sentinel on disk but reads back as NaN, or the int-sentinel equivalent for uint8.T-7: COG validity. The writer has a
cog=Truemode but no test confirms the output passes a third-party COG check (overview list, GDALLAYOUT=COGtag). Use rasterio when present, skip otherwise.T-9: write-to-readonly path. No test confirms that writing to a non-writable directory raises a clean OSError/PermissionError rather than a confusing deep-stack failure.
T-10: planar config 2 round-trip. Not applicable on the write side.
_writer.pydoesn't emitPlanarConfiguration=2(only the reader supports it). Dropped from this issue; could be tracked separately as a writer feature.Acceptance: tests land in
xrspatial/geotiff/tests/test_writer.py(or a newtest_writer_matrix.py) and pass on CI. Rasterio-dependent COG check skips when rasterio is missing.