geotiff: reject (y, x, time) 3D writer inputs (#1972)#1982
Merged
Conversation
(time, y, x) was already caught by _validate_3d_writer_dims (issue #1812), but the symmetric (y, x, time) slipped through the (y, x, *) band-position fallback and was silently written as a 3-band TIFF. Round-tripping a temporal stack therefore produced a file that looked like a multiband raster. Add _TIME_DIM_NAMES in _runtime.py (time / t / date / datetime / times / dates) and check the trailing dim against it in _validate_3d_writer_dims. Known temporal names raise with a message suggesting isel / mean / rename-to-band; the (y, x, *) fallback for genuinely unknown trailing dim names stays in place so raw numpy callers building band-last arrays are not bounced.
Contributor
Author
PR Review (self-review)Suggestions
Nits
What looks good
Checklist
|
- lower-case the trailing dim before matching against _TIME_DIM_NAMES via a
new _is_temporal_dim_name helper, so ('y', 'x', 'TIME') and
('y', 'x', 'Time') hit the friendly temporal error instead of slipping
through the (y, x, *) fallback and writing a 3-band TIFF
- emit the same temporal-specific message for the leading-dim case
('time', 'y', 'x') / ('TIME', 'y', 'x') instead of the generic
ambiguous-dims wording
- add regression tests for the mixed-case trailing and leading paths
- update the #1812 tests that asserted the generic message for
('time', 'y', 'x') to accept either wording, and switch the
actionable-message test to a non-temporal leading dim
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.
Closes #1972.
Summary
_validate_3d_writer_dimsnow refuses 3D writer inputs whose trailing dim is a known temporal name (time,t,date,datetime,times,dates). The mirror case(time, y, x)was already rejected by the existing layout check; this closes the asymmetry.isel, a reduction, or a rename tobandif the temporal axis is genuinely the band axis.(y, x, *)fallback for raw numpy callers building band-last arrays stays in place for genuinely unknown trailing dim names.Test plan
xrspatial/geotiff/tests/test_temporal_3d_writer_rejection_1972.pycovers each temporal alias, each y/x alias, the band-leading and band-trailing accept cases, the regression on(time, y, x), and the writer entry point round trip.pytest xrspatial/geotiff/tests/— same 8 pre-existing failures as main, none related.