Add test for cost_distance dask all-impassable early return (#3367)#3368
Merged
brendancol merged 2 commits intoJun 17, 2026
Merged
Conversation
brendancol
commented
Jun 16, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
PR Review: Add test for cost_distance dask all-impassable early return (#3367)
Blockers
None.
Suggestions
None.
Nits
None.
What looks good
- The test hits the intended branch. All-zero friction makes
da.where(friction_da > 0, friction_da, np.inf)all-inf, soda.nanminreturns inf,np.isfinite(f_min)is False, and_cost_distance_dasktakes theda.full(..., np.nan)early return at cost_distance.py:1150 instead of map_overlap or the iterative tile Dijkstra. - The three assertions match that branch's contract: all-NaN output, dask-backed result,
npartitions > 1(chunking preserved). - The PR proves the early return is reached via
-W error::UserWarning. The iterative path raises a UserWarning, so its absence pins the branch and stops the test from silently drifting onto the iterative path later. - Test-only change, source untouched. No backend-parity or numerical-correctness risk.
Checklist
- NaN handling correct: yes (asserts all-NaN)
- Edge case covered: yes (adds the missing all-impassable dask case)
- Dask chunking handled: yes (asserts npartitions > 1)
- No premature materialization: yes (single _compute at the end)
- Benchmark: not needed (test-only)
- Docstring present: yes (explains the branch)
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 #3367
What
Adds one test (
test_dask_all_impassable_friction_returns_nan) covering thef_min <= 0early return in_cost_distance_dask. When friction has no passable cell andmax_costis finite, that branch short-circuits toda.full(..., nan)and keeps the input chunking, instead of runningmap_overlapor the iterative tile Dijkstra. Nothing reached this branch before.The test builds an all-zero-friction dask+numpy raster with
max_cost=5.0and asserts the result is all-NaN, dask-backed, and keeps more than one partition.Backend coverage
Test-only change, dask+numpy path. Source untouched.
Test plan
test_dask_all_impassable_friction_returns_nanpasses-W error::UserWarningconfirms the early return is taken (no "iterative tile Dijkstra" warning)test_cost_distance.pygreen on a CUDA host (85 passed)