Skip to content

Add backend statement and Examples section to cost_distance docstring#3642

Merged
brendancol merged 1 commit into
xarray-contrib:mainfrom
Melissari1997:issue-3587
Jul 7, 2026
Merged

Add backend statement and Examples section to cost_distance docstring#3642
brendancol merged 1 commit into
xarray-contrib:mainfrom
Melissari1997:issue-3587

Conversation

@Melissari1997

Copy link
Copy Markdown
Collaborator

Closes #3587.

  • Adds backend support paragraph (NumPy, CuPy, Dask+NumPy, Dask+CuPy)
  • Adds a .. sourcecode:: python Examples block with a 3x3 uniform-friction example
  • Adds a pin test verifying the backend sentence and a test that the example output matches the implementation
  • No behaviour changes

Test plan

  • test_docstring_states_all_backends -- passes
  • test_docstring_example_matches_output -- passes
  • Full test_cost_distance.py suite: 79 passed, 12 skipped (GPU-only)

@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Jul 7, 2026

@Melissari1997 Melissari1997 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: Add backend statement and Examples section to cost_distance docstring

Blockers

None.

Suggestions

None.

Nits

None.

What looks good

  • Backend statement matches the phrasing used by proximity, allocation, and direction in proximity.py, and accurately reflects the four backends (numpy, cupy, dask+numpy, dask+cupy) already dispatched in cost_distance.
  • Examples section uses the .. sourcecode:: python convention, includes runnable >>> blocks with expected output, and is verified by the pin test test_docstring_example_matches_output so the printed output cannot drift.
  • Pin test test_docstring_states_all_backends follows the same pattern as the existing tests in test_proximity.py (from issue #3091) and guards against the old wording coming back.
  • The new tests pass: both docstring pin and example-output tests succeed alongside the full test_cost_distance.py suite (79 passed, 12 skipped).
  • No behaviour changes, no dispatch or algorithm modifications -- pure doc and test addition.

Checklist

  • Algorithm matches reference/paper — N/A (no algorithm change)
  • All implemented backends produce consistent results — verified by existing tests
  • NaN handling is correct — N/A
  • Edge cases are covered by tests — existing coverage is adequate
  • Dask chunk boundaries handled correctly — N/A
  • No premature materialization or unnecessary copies — N/A
  • Benchmark exists or is not needed — N/A (doc-only)
  • README feature matrix updated — N/A (no new function)
  • Docstrings present and accurate — verified

@brendancol brendancol self-requested a review July 7, 2026 18:56

@brendancol brendancol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brendancol brendancol merged commit bf58b35 into xarray-contrib:main Jul 7, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cost_distance docstring: no Examples section, backend support unstated

2 participants