geotiff: backend-parity tests for bool nodata rejection (#1921)#1924
Merged
brendancol merged 2 commits intoMay 15, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds test coverage to ensure GeoTIFF/VRT writer entry points consistently reject nodata=True/False (and np.bool_) by raising TypeError, and records the sweep-test-coverage state update for issue #1921 tracking.
Changes:
- Add new backend-parity tests covering
write_vrtbool-nodata behavior (including strict xfails for the expected future fix). - Add GPU-path tests pinning bool-nodata rejection for direct
write_geotiff_gpucalls and theto_geotiff(gpu=True)dispatch path. - Update
.claude/sweep-test-coverage-state.csvto record sweep pass 15 / issue #1921 metadata.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
xrspatial/geotiff/tests/test_write_vrt_bool_nodata_1921.py |
Introduces new parity tests for bool/np.bool_ nodata rejection across write_vrt and GPU writer paths. |
.claude/sweep-test-coverage-state.csv |
Updates sweep-test-coverage tracking state for geotiff module / issue #1921. |
Comments suppressed due to low confidence (1)
xrspatial/geotiff/tests/test_write_vrt_bool_nodata_1921.py:145
- These tests should be skipped with the repo-standard GPU marker (reason "cupy + CUDA required") rather than only checking
_HAS_CUPYwith reason "cupy not available". As written, they may run (and fail) when CuPy is installed but CUDA is unavailable; consider replacing with@requires_gpufromgeotiff/tests/conftest.py.
@pytest.mark.skipif(not _HAS_CUPY, reason="cupy not available")
@pytest.mark.parametrize(
"bad",
[True, False, np.bool_(True), np.bool_(False)],
)
def test_write_geotiff_gpu_rejects_bool_nodata(uint8_da, tmp_path, bad):
"""Direct ``write_geotiff_gpu`` call rejects bool nodata.
Currently raises ``TypeError`` only because the deeper
``build_geo_tags`` guard fires. Pinning the behaviour so a refactor
that drops the deeper guard surfaces here, not in user code.
"""
from xrspatial.geotiff import write_geotiff_gpu
path = str(tmp_path / "gpu_1921_bad.tif")
with pytest.raises(TypeError, match="nodata must be numeric"):
write_geotiff_gpu(uint8_da, path, nodata=bad)
@pytest.mark.skipif(not _HAS_CUPY, reason="cupy not available")
def test_to_geotiff_gpu_dispatch_rejects_bool_nodata(uint8_da, tmp_path):
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from __future__ import annotations | ||
|
|
||
| import os | ||
| import tempfile |
|
|
||
|
|
||
| def test_write_vrt_with_bool_nodata_currently_emits_string( | ||
| src_geotiff, tmp_path): |
Comment on lines
+33
to
+34
| import cupy # noqa: F401 | ||
| _HAS_CUPY = True |
Pin two parity gaps the #1911 fix left open: * write_vrt(nodata=True) currently writes <NoDataValue>True</NoDataValue> into the VRT XML. Four xfail(strict=True) tests cover the fix surface and one passing test pins the buggy emission so the source fix shows up as a diff. Tracked in issue #1921. * write_geotiff_gpu direct call rejects bool nodata only via the deeper build_geo_tags guard. Add a top-of-call parity test so a refactor that drops the deeper check surfaces here, not in user code. Also pin to_geotiff(gpu=True, nodata=True) so the dispatch order keeps firing the eager guard before reaching the GPU writer. Found by /sweep-test-coverage pass 15.
- Remove unused tempfile import (F401) - Switch GPU gating from local _HAS_CUPY import check to requires_gpu from conftest, which also verifies the CUDA runtime is usable
45593cd to
4b3cc92
Compare
3 tasks
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.
Summary
to_geotiffbool-nodata guard from geotiff: to_geotiff(nodata=True) silently writes unparseable "True" tag #1911.write_vrtand directwrite_geotiff_gpucalls were missed by the original fix.xfail(strict=True)tests onwrite_vrtcapture the fix surface for issue geotiff: write_vrt(nodata=True) silently writes 'True' string into VRT XML #1921. One passing test pins the current buggy<NoDataValue>True</NoDataValue>emission so the source fix shows up as a diff.write_geotiff_gpudirect-call tests pin the existing rejection (driven by thebuild_geo_tagsdefense-in-depth guard) so a future refactor that moves that check surfaces here instead of in user code.Test-only PR; source fix tracked in #1921. Found by
/sweep-test-coveragepass 15.Test plan
pytest xrspatial/geotiff/tests/test_write_vrt_bool_nodata_1921.py-> 13 passed, 4 xfailed locallypytest xrspatial/geotiff/tests/test_nodata_bool_rejection_1911.pystill green (no overlap regression)