geotiff: refuse non-numeric nodata / _FillValue early (#1973)#1983
Open
brendancol wants to merge 1 commit into
Open
geotiff: refuse non-numeric nodata / _FillValue early (#1973)#1983brendancol wants to merge 1 commit into
brendancol wants to merge 1 commit into
Conversation
attrs['_FillValue']='missing' (or attrs['nodata']='missing', or a non-numeric nodata= kwarg) used to crash deep inside the writer with ``ufunc 'isnan' not supported``. The TypeError did not name the offending attribute and gave no hint that nodata was the cause. Add _validate_nodata_arg in _validation.py and call it from to_geotiff, _write_vrt_tiled, and write_geotiff_gpu so the kwarg path is checked at the boundary. Tighten _resolve_nodata_attr to raise ValueError naming the bad attr when attrs['nodata'] or attrs['_FillValue'] is non-numeric. The rioxarray-style attrs['nodatavals'] branch keeps its existing skip-on-non-numeric behaviour (per-band tuples often carry placeholder entries from arbitrary upstream pipelines, so a single bad entry should not block writing).
Contributor
Author
PR Review (self-review)Suggestions
Nits
What looks good
Checklist
|
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 #1973.
Summary
_validate_nodata_argrejects non-numericnodata=kwargs at the writer entry point.to_geotiff,_write_vrt_tiled, andwrite_geotiff_gpuall call it before any downstreamnp.isnanusage._resolve_nodata_attrnow raisesValueErrornaming the offending attribute whenattrs['nodata']orattrs['_FillValue']is non-numeric, instead of returning the value verbatim and letting NumPy crash later with a generic ufunc TypeError.attrs['nodatavals'](rioxarray's per-band tuple) keeps its existing skip-on-non-numeric behaviour, since those values often come from arbitrary upstream pipelines and a single bad entry should not block writing.Test plan
xrspatial/geotiff/tests/test_nodata_validation_1973.pycovers_validate_nodata_arg,_resolve_nodata_attr(both attrs), the writer kwarg path, the_FillValueattr path, and the.vrtdispatch path.pytest xrspatial/geotiff/tests/— same 8 pre-existing failures as main, none related.