Summary
Follow-up under epic #2211. Phase 5f deliverable: extract the write-side encode helpers (strip/tile encode + photometric + predictor + compression block) out of _writer.py into a new _encode.py. Mirrors the _decode.py extraction (PR-G) on the read side.
Scope
Mechanical extraction. Behavior-neutral.
Hold for dispatch until PR-K (_overview.py) merges — both PRs touch _writer.py and serial landing avoids a heavy rebase.
Files
- Create:
xrspatial/geotiff/_encode.py.
- Modify:
xrspatial/geotiff/_writer.py — remove the helpers being moved; import them from _encode.
- Modify: any module that imports those helpers (likely
_writers/eager.py, _writers/gpu.py, _writers/vrt.py).
What to move
Encode helpers in _writer.py (verify each name in the current file post-PR-K):
_invert_nodata_for_miniswhite
_apply_photometric_miniswhite_invert
_resolve_photometric
_reject_disagreeing_photometric_override
normalize_predictor
_apply_predictor_encode
_compression_tag
_prepare_strip
_write_stripped
_prepare_tile
_write_tiled
_compress_block
Leave in _writer.py: _write, _write_streaming, _validate_lowlevel_write_kwargs, fsspec write helpers.
Acceptance
_writer.py line count drops by ~500 lines. Combined with PR-I and PR-K, target ending around ~1300 lines.
- All encode-related tests pass unchanged: photometric, predictor, strip/tile encode, miniswhite invert, compression tag, plus the broader geotiff write suite.
- Public import paths preserved.
- No public API change.
Non-goals
- Splitting
_write / _write_streaming further.
- Performance work.
Closes part of #2211.
Summary
Follow-up under epic #2211. Phase 5f deliverable: extract the write-side encode helpers (strip/tile encode + photometric + predictor + compression block) out of
_writer.pyinto a new_encode.py. Mirrors the_decode.pyextraction (PR-G) on the read side.Scope
Mechanical extraction. Behavior-neutral.
Hold for dispatch until PR-K (
_overview.py) merges — both PRs touch_writer.pyand serial landing avoids a heavy rebase.Files
xrspatial/geotiff/_encode.py.xrspatial/geotiff/_writer.py— remove the helpers being moved; import them from_encode._writers/eager.py,_writers/gpu.py,_writers/vrt.py).What to move
Encode helpers in
_writer.py(verify each name in the current file post-PR-K):_invert_nodata_for_miniswhite_apply_photometric_miniswhite_invert_resolve_photometric_reject_disagreeing_photometric_overridenormalize_predictor_apply_predictor_encode_compression_tag_prepare_strip_write_stripped_prepare_tile_write_tiled_compress_blockLeave in
_writer.py:_write,_write_streaming,_validate_lowlevel_write_kwargs, fsspec write helpers.Acceptance
_writer.pyline count drops by ~500 lines. Combined with PR-I and PR-K, target ending around ~1300 lines.Non-goals
_write/_write_streamingfurther.Closes part of #2211.