Describe the bug
The gpu flag on the GeoTIFF read and write entry points is consumed by truthiness instead of being validated as a real bool.
open_geotiff(..., gpu=...) branches on if gpu: at xrspatial/geotiff/__init__.py:912.
to_geotiff(..., gpu=...) resolves use_gpu = gpu if gpu is not None else _is_gpu_data(data) at xrspatial/geotiff/_writers/eager.py:582.
"False" is a non-empty string, so gpu="False" is truthy and selects the GPU path instead of raising. Pass a stringified bool (easy to do when a flag comes from a CLI arg, env var, or config file) and you get the opposite of what you asked for, with no error. A dispatch flag that picks the wrong backend silently is a correctness hazard in an I/O module.
Expected behavior
Validate gpu as an actual bool before any branch reads it, and raise TypeError with a clear message otherwise. The read path defaults gpu to False (bool only). The write path types it as bool | None, where None means "auto-detect from the data", so None stays valid there.
gpu="False", gpu=1, and gpu=0 should raise. gpu=True and gpu=False keep working as before.
Severity
Medium. Silent wrong-backend dispatch. Not a crash or data loss, but hard to notice.
Describe the bug
The
gpuflag on the GeoTIFF read and write entry points is consumed by truthiness instead of being validated as a real bool.open_geotiff(..., gpu=...)branches onif gpu:atxrspatial/geotiff/__init__.py:912.to_geotiff(..., gpu=...)resolvesuse_gpu = gpu if gpu is not None else _is_gpu_data(data)atxrspatial/geotiff/_writers/eager.py:582."False"is a non-empty string, sogpu="False"is truthy and selects the GPU path instead of raising. Pass a stringified bool (easy to do when a flag comes from a CLI arg, env var, or config file) and you get the opposite of what you asked for, with no error. A dispatch flag that picks the wrong backend silently is a correctness hazard in an I/O module.Expected behavior
Validate
gpuas an actualboolbefore any branch reads it, and raiseTypeErrorwith a clear message otherwise. The read path defaultsgputoFalse(bool only). The write path types it asbool | None, whereNonemeans "auto-detect from the data", soNonestays valid there.gpu="False",gpu=1, andgpu=0should raise.gpu=Trueandgpu=Falsekeep working as before.Severity
Medium. Silent wrong-backend dispatch. Not a crash or data loss, but hard to notice.