pathfinding: add multi_stop_search Examples, fix sourcecode directive, document NaN impassability (#3651)#3662
Open
brendancol wants to merge 2 commits into
Open
Conversation
…e directive, NaN semantics (#3651) - Add a runnable Examples section to multi_stop_search (verified output) - Fix a_star_search's '... sourcecode:: python' directive (three dots rendered as literal text; every other module uses two) - Document that NaN surface cells are always impassable, regardless of the barriers list, in both public docstrings - Fix 'y: str' numpydoc spacing in a_star_search - Add docstring-validation tests (params-match-signature, structure, example output) to test_pathfinding.py - Update documentation sweep state CSV 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.
PR Review: pathfinding: add multi_stop_search Examples, fix sourcecode directive, document NaN impassability (#3651)
Blockers (must fix before merge)
None.
Suggestions (should fix, not blocking)
-
xrspatial/pathfinding.py:871-874: the PR fixes they: strnumpydoc spacing but leaves the same defect on the next two entries,snap_start: bool, default=Falseandsnap_goal: bool, default=False. Since the diff already touches this Parameters section for the identical reason, fix all three, not one.
Nits (optional improvements)
-
xrspatial/pathfinding.py:1449-1452: the new example pins full-precision float reprs (2.8284271247461903). Rounding in the example would be less brittle if the cost model ever changes. That said,test_multi_stop_search_docstring_examplepins the same values, so any drift will surface as a test failure rather than a silently stale docstring. Fine either way.
What looks good
- The new
multi_stop_searchexample was executed and its printed attrs match real output (waypoint_order,segment_costs,total_costall verified; the waypoints avoid barrier cells). - The
... sourcecode::->.. sourcecode::fix matches the two-dot form used everywhere else in the codebase. - The NaN wording matches actual behavior:
_is_not_crossable(pathfinding.py:68-77) rejects NaN cells before consultingbarriers, and the existinginput_data_with_nanstests pin it. The docstring now says so in both the summary and thebarriersentries. - The three new tests follow existing project patterns (
test_multispectral.py::test_docstring_params_match_signature, phrase-pinning as intest_proximity.py::test_docstring_states_all_backends), and the params check correctly handles the groupedx, y : strentry. - Doc-only change; no function behavior touched. The known-wrong
surfacedescription and emptyconnectivityentry are deliberately left to #3644, which already tracks them.
Checklist
- Algorithm matches reference/paper (n/a, docstrings and tests only)
- All implemented backends produce consistent results (backend table re-verified on numpy/cupy/dask+numpy/dask+cupy; unchanged by this PR)
- NaN handling is correct (documentation now matches implementation)
- Edge cases are covered by tests (docstring structure, signature match, example output)
- Dask chunk boundaries handled correctly (n/a)
- No premature materialization or unnecessary copies (n/a)
- Benchmark exists or is not needed (not needed; doc-only)
- README feature matrix updated (n/a, no new functions or backend changes)
- Docstrings present and accurate
brendancol
commented
Jul 8, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
PR Review follow-up (post-fix pass)
Re-checked the branch after 9d9af36.
- Suggestion (snap_start/snap_goal numpydoc spacing): fixed in 9d9af36. All three Parameters entries in
a_star_searchnow use thename : typeform;grep -n '^\s*\w\+:'over the docstring finds no remaining offenders. - Nit (full-precision floats in the example): kept as is. Pinning real printed output matches the existing precedent (
allocation's example andtest_allocation_docstring_example), andtest_multi_stop_search_docstring_examplefails loudly if the values ever drift.
Docstring tests still pass (5/5), no new flake8 findings. Nothing further from me.
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 #3651
Doc-only changes to
xrspatial/pathfinding.py, found by the documentation sweep:multi_stop_search(it had none;a_star_searchhas one). The example runs as written and itswaypoint_order/segment_costs/total_costoutputs were verified on this host.... sourcecode:: pythondirective ina_star_search's Examples (three dots instead of two, the only occurrence in the codebase; it rendered as literal text instead of a code block).barrierslist, in both public docstrings. The behavior is implemented in_is_not_crossableand pinned by existing tests; only the friction NaN rule was documented before.y: strtoy : strina_star_search's Parameters (numpydoc spacing).No behavior changes. The wrong
surfacedescription ("values to bin") and the emptyconnectivitydescription are left for #3644, which already tracks them.Tests: adds
test_docstring_params_match_signature(parametrized over both public functions, modeled on the multispectral check with support for groupedx, y : strentries),test_docstring_structure(required sections present, two-dot directive, NaN wording pinned), andtest_multi_stop_search_docstring_example(runs the new example and pins its attrs output).Test plan:
pytest xrspatial/tests/test_pathfinding.py- 62 passed (57 existing + 5 new)Backend coverage: n/a (docstrings and tests only). The backend-support table in
a_star_search's docstring was checked against all four backends (numpy, cupy, dask+numpy, dask+cupy) on this host and is accurate as written.https://claude.ai/code/session_0155N4QGamQVxgpAAPbpQNq4