Skip to content

stream_order_d8: accept method alias; basins_d8: emit DeprecationWarning#2716

Open
brendancol wants to merge 3 commits into
mainfrom
deep-sweep-api-consistency-hydro-d8-2026-05-29
Open

stream_order_d8: accept method alias; basins_d8: emit DeprecationWarning#2716
brendancol wants to merge 3 commits into
mainfrom
deep-sweep-api-consistency-hydro-d8-2026-05-29

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #2709

What changed

  • stream_order_d8 now accepts a method keyword as an alias for ordering. This matches stream_order_dinf and stream_order_mfd, which already name the strahler/shreve selector method. ordering keeps working, so existing callers and the stream_order(routing=...) dispatcher (which passes ordering=) are unaffected. Passing both ordering and method with conflicting values raises ValueError.
  • basins_d8 (the backward-compatible wrapper for basin_d8) now emits a DeprecationWarning, which its docstring already pointed users toward.

A full rename of ordering to method was avoided on purpose: the dispatcher in xrspatial/hydro/__init__.py (out of scope for this D8 sweep) passes ordering= straight to the D8 path, so deprecating ordering now would warn on every unified stream_order(routing='d8') call.

Backend coverage

The selector is a plain string passed to every backend, so the alias behaves the same on numpy, cupy, dask+numpy, and dask+cupy. Verified method/ordering parity on numpy and on a cupy DataArray.

Test plan

  • method alias produces the same result as ordering (numpy)
  • method parity on a cupy DataArray
  • invalid method value raises ValueError
  • conflicting ordering + method raises ValueError
  • basins_d8 emits DeprecationWarning and still returns the basin result
  • existing stream_order_d8 and watershed_d8 suites pass (70 passed)

…ing (#2709)

stream_order_d8 now accepts a method kwarg as an alias for ordering, matching
the parameter name used by stream_order_dinf and stream_order_mfd. ordering
keeps working unchanged so existing callers and the routing dispatcher are
unaffected; passing both with conflicting values raises ValueError.

basins_d8 (a backward-compat wrapper for basin_d8) now emits a
DeprecationWarning, matching its docstring guidance.
…2709)

- Normalize ordering/method case before the conflict check so an explicit
  ordering='Strahler' alongside method='shreve' is not flagged as a conflict.
- Type method as 'str | None' to match its None default and the docstring.
- Add a regression test for the case-insensitive non-conflict path.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 29, 2026
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.

stream_order_d8 uses ordering kwarg while dinf/mfd siblings use method

1 participant