Resample polish: fix cubic depth comment, tighten NaN threshold, add edge tests#1475
Resample polish: fix cubic depth comment, tighten NaN threshold, add edge tests#1475brendancol merged 4 commits intomainfrom
Conversation
- Reword cubic _INTERP_DEPTH comment: depth 10 brings the boundary transient to ~1e-7, not float64 machine epsilon. - Raise nan-aware kernel-weight gate from 0.01 to 0.5 in the numpy, cupy, and dask block variants. Pixels lit only by cubic-kernel sidelobes from a single neighbour now come back as NaN. - Add tests for descending-y orientation, +/- inf input propagation, the 3D-rejection error message, and bit-identical repeat output for bilinear / cubic / average.
|
@copilot resolve the merge conflicts in this pull request |
# Conflicts: # xrspatial/tests/test_resample.py Co-authored-by: brendancol <433221+brendancol@users.noreply.github.com>
…for new 3D support Agent-Logs-Url: https://github.com/xarray-contrib/xarray-spatial/sessions/441b5d81-2d7b-4c7b-bb38-13afa95bbc77 Co-authored-by: brendancol <433221+brendancol@users.noreply.github.com>
…e tests into first class Agent-Logs-Url: https://github.com/xarray-contrib/xarray-spatial/sessions/441b5d81-2d7b-4c7b-bb38-13afa95bbc77 Co-authored-by: brendancol <433221+brendancol@users.noreply.github.com>
Merge conflicts resolved in e5e4090. The conflict in |
Closes #1471.
Changes
_INTERP_DEPTHcomment inxrspatial/resample.py. The previous comment claimed depth 10 brings the prefilter transient to "machine epsilon"; the actual value0.268^10is about4e-7, closer to float32 epsilon. The constant 10 is unchanged because it remains correct for float32 output.z_wt > 0.01toz_wt > 0.5in_nan_aware_interp_np,_nan_aware_interp_cupy,_interp_block_np, and_interp_block_cupy. With the old threshold, an output pixel could pass through the gate when only a small fraction of the resampling kernel weight came from valid input pixels (one cubic sidelobe leaks about 5% from a single neighbour). The new threshold means more than half of the kernel weight must come from valid pixels. A short comment in_nan_aware_interp_npexplains the choice; the other three sites point back to it.+infand-infpropagate (not coerced to NaN) for bilinear, average, and nearest.resample(...)produces bit-identical output across two consecutive calls for bilinear, cubic, and average.Behavior change
The NaN threshold bump is the only behavior change. Output pixels in the [0.01, 0.5] kernel-weight band, which previously came back as a fractional value, now come back as NaN. This is a more conservative gate.
Test plan
pytest xrspatial/tests/test_resample.py(62 -> 70, all pass)