Describe the bug
resample() does not cleanly reject empty rasters on the scale_factor path. _validate_raster() checks dimensionality and numeric dtype, but not for zero-sized spatial axes. When a raster with a zero-length spatial axis (0 rows or 0 columns) is passed with scale_factor, the call reaches coordinate indexing and surfaces an IndexError instead of a clear ValueError.
The target_resolution path already guards against this with a check requiring at least 2 pixels per dimension, but the scale_factor path has no equivalent guard.
The existing coverage test (TestEmptyRasterRejected in test_resample_coverage_2026_05_27.py) currently accepts either IndexError or ValueError, so the contract is acknowledged but not watertight.
Expected behavior
A public function should raise a clear ValueError up front, before reaching coordinate indexing, when handed a raster with a zero-sized spatial axis.
Fix
Extend _validate_raster() (or the scale_factor path) to detect zero-sized spatial axes and raise a clear ValueError, then tighten the coverage test to expect ValueError specifically.
Additional context
Found during a code review of the resample input-validation path.
Describe the bug
resample()does not cleanly reject empty rasters on thescale_factorpath._validate_raster()checks dimensionality and numeric dtype, but not for zero-sized spatial axes. When a raster with a zero-length spatial axis (0 rows or 0 columns) is passed withscale_factor, the call reaches coordinate indexing and surfaces anIndexErrorinstead of a clearValueError.The
target_resolutionpath already guards against this with a check requiring at least 2 pixels per dimension, but thescale_factorpath has no equivalent guard.The existing coverage test (
TestEmptyRasterRejectedintest_resample_coverage_2026_05_27.py) currently accepts eitherIndexErrororValueError, so the contract is acknowledged but not watertight.Expected behavior
A public function should raise a clear
ValueErrorup front, before reaching coordinate indexing, when handed a raster with a zero-sized spatial axis.Fix
Extend
_validate_raster()(or thescale_factorpath) to detect zero-sized spatial axes and raise a clearValueError, then tighten the coverage test to expectValueErrorspecifically.Additional context
Found during a code review of the resample input-validation path.