Route the HPA* coarse grid without value barriers#3659
Merged
Conversation
Coarse cell values are block means of the non-barrier fine cells, so testing them against the exact barrier values can falsely block a passable block whose values average to a barrier value (e.g. -1/+1 data with barriers=[0] gives every block mean 0.0), turning a fully passable grid into all-NaN "no path". _coarsen_surface already encodes fully-barrier blocks as NaN, so the coarse route now runs with an empty barrier list. Claude-Session: https://claude.ai/code/session_0155N4QGamQVxgpAAPbpQNq4
brendancol
commented
Jul 8, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
Domain-aware review of the HPA* coarse-barrier fix.
Blockers
None.
Suggestions
- The empty array reuses
barriers.dtype, which keeps the numba signature of_a_star_searchstable across the coarse and fine calls when callers pass integer barrier lists. Good; a barenp.array([])would have forced a second float64 specialization but also worked. No change needed.
Nits
- The fix only touches the coarse route. Refinement (
_bounded_a_star_sub) still runs on the fine grid with the caller's barriers, so true barriers keep constraining the actual path; the change removes only the mean-aliasing false blocks. The pre-existing semantics that a block with any single crossable cell is coarse-passable are unchanged, and the radius-escalation loop plus the #3638 all-NaN contract still cover refinement dead-ends.
Verified locally: the new test returns 0 finite pixels on main and a connected start-to-goal path with the fix; the issue's end-to-end repro (600x600, mocked RAM so auto-radius HPA* engages, barriers=[0]) reaches the goal after the fix; test_hpa_star_correctness and test_hpa_star_unreachable_goal_all_nan still pass (58 total).
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.
Closes #3647
_hpa_star_searchnow routes the coarsened grid with an empty barrier list. Coarse cell values are block means of the non-barrier fine cells, so testing them against the exact barrier values could falsely block a passable block whose values average to a barrier value (alternating -1/+1 data withbarriers=[0]makes every block mean exactly 0.0, blocking the whole coarse grid and returning all-NaN "no path" on a fully passable surface)._coarsen_surfacealready marks fully-barrier blocks as NaN, and NaN cells stay impassable in the coarse search, so no blocking information is lost. Refinement still runs on the fine grid with the caller's barriers.Backends: HPA* runs on the numpy and cupy (CPU-fallback) paths only; the dask sparse A* never coarsens.
Test plan:
test_hpa_star_barrier_valued_block_means(fails on main: 0 finite pixels)pytest xrspatial/tests/test_pathfinding.py— 58 passed, including the existing HPA* correctness and all-NaN no-path testsAlso includes this sweep's state-CSV update.
https://claude.ai/code/session_0155N4QGamQVxgpAAPbpQNq4