Describe the bug
xrspatial/geotiff/_reader.py:1963-1964:
```python
if arr.ndim == 3 and ifd.samples_per_pixel > 1 and band is not None:
arr = arr[:, :, band]
```
No validation. band=-1 silently selects the last channel via numpy negative indexing. band=N where N >= samples_per_pixel raises a raw IndexError. The dask and GPU paths validate band against samples_per_pixel and raise ValueError; the local eager path does not.
Same public call (open_geotiff, read_to_array), different error behavior per backend.
Expected behavior
band outside [0, samples_per_pixel - 1] raises ValueError regardless of which backend resolves the read. The message should name samples_per_pixel so users can correct the call.
Suggested fix
Add a validation block before the slice that matches the dask path. Cover the HTTP path at the same time so backend parity holds across local, HTTP, dask, and GPU.
Add a backend-parity test that calls each path with band=-1 and band=samples_per_pixel and asserts the same ValueError text shape.
Additional context
Reported during a code review of the geotiff module.
Describe the bug
xrspatial/geotiff/_reader.py:1963-1964:```python
if arr.ndim == 3 and ifd.samples_per_pixel > 1 and band is not None:
arr = arr[:, :, band]
```
No validation.
band=-1silently selects the last channel via numpy negative indexing.band=NwhereN >= samples_per_pixelraises a rawIndexError. The dask and GPU paths validatebandagainstsamples_per_pixeland raiseValueError; the local eager path does not.Same public call (
open_geotiff,read_to_array), different error behavior per backend.Expected behavior
bandoutside[0, samples_per_pixel - 1]raisesValueErrorregardless of which backend resolves the read. The message should namesamples_per_pixelso users can correct the call.Suggested fix
Add a validation block before the slice that matches the dask path. Cover the HTTP path at the same time so backend parity holds across local, HTTP, dask, and GPU.
Add a backend-parity test that calls each path with
band=-1andband=samples_per_pixeland asserts the sameValueErrortext shape.Additional context
Reported during a code review of the geotiff module.