Skip to content

Remove deprecated hydro, zonal, focal and classify aliases for 1.0.0 - #3767

Open
brendancol wants to merge 3 commits into
mainfrom
issue-3762
Open

brendancol wants to merge 3 commits into
mainfrom
issue-3762

Conversation

@brendancol

@brendancol brendancol commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3762

1.0.0 breaking change: the deprecated spellings in hydro, zonal, focal and classify are gone. Each one warned with DeprecationWarning on 0.10.x. Replacements are on the migration page from #3761 (docs/source/user_guide/migration_1_0.rst).

Removed Use instead
xrspatial.basins, xrspatial.hydro.basins, hydro.watershed_d8.basins_d8, .xrs.basins() basin / basin_d8 / .xrs.basin()
crop(zones_ids=...) and .xrs.crop(zones, zones_ids=...) crop(zone_ids=...) / .xrs.crop(zones, zone_ids=...)
focal.apply(raster=...), hotspots(raster=...) agg= (now the required first parameter)
natural_breaks(agg, 20000, k=3) positional num_sample remap natural_breaks(agg, k=3, num_sample=20000)

Old spellings now raise the ordinary TypeError / AttributeError; no custom messages. The _resolve_raster_alias helper and the _natural_breaks_legacy_order wrapper are deleted, along with their orphaned imports.

Tests: the alias tests are replaced by one removal test per alias. The 3_Zonal notebook used zones_ids=; it now uses zone_ids=. basins_d8 dropped from the hydrology autosummary.

Overlap: this PR also removes the from xrspatial.hydro import basins line in xrspatial/__init__.py, which the surface-freeze branch issue-2930 removes too. Whichever merges second gets a one-line re-merge.

Backends: no runtime path changes; all four backends unaffected beyond the removed keyword.

Test plan:

  • test_classify.py, test_focal.py, test_accessor.py, hydro/tests/test_watershed_d8.py, test_routing_public_api.py, test_basin_d8.py: 672 passed locally
  • test_zonal.py: 192 passed locally
  • CI green

@brendancol brendancol left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PR Review: Remove deprecated hydro, zonal, focal and classify aliases for 1.0.0

Blockers (must fix before merge)

  • none

Suggestions (should fix, not blocking)

  • xrspatial/accessor.py:1304: the second commit renames the accessor's crop(self, zones, zones_ids, **kwargs) parameter to zone_ids. That is a user-visible removal on the .xrs surface (da.xrs.crop(zones, zones_ids=[...]) now raises), and neither the PR body nor the migration page in #3761 lists it. Add it to both so the 1.0 migration table is complete.

Nits (optional improvements)

  • xrspatial/tests/test_zonal.py:2262 test_crop_zone_ids_does_not_warn filters caught warnings for the string zones_ids, which nothing emits any more. It still guards "the canonical kwarg does not warn", so keeping it is fine; the filter string is just stale.

What looks good

  • apply and hotspots go back to a required positional agg, so a missing input raises Python's own TypeError instead of the hand-rolled one. supports_dataset binds the first parameter by name from inspect.signature, so the Dataset path still works (test_dataset_support.py passes, 20 tests).
  • _resolve_raster_alias, _natural_breaks_legacy_order, basins_d8, the basins dispatcher, both accessor basins methods and the _DOC_SOURCE_OVERRIDES entry are all gone together; no orphaned import (warnings in focal, functools in classify) is left behind.
  • Every removed alias has a replacement test asserting the ordinary error, and test_routing_public_api / test_accessor parameter lists were trimmed so they do not reference removed names.
  • The 3_Zonal notebook cell was updated, so the one example that used zones_ids= keeps working.
  • Local runs: 672 passed (classify, focal, hydro, accessor), 192 passed (zonal), 98 passed (accessor after the rename).

Checklist

  • Algorithm matches reference/paper (n/a, no numerical change)
  • All implemented backends produce consistent results (no backend path touched)
  • NaN handling is correct (unchanged)
  • Edge cases are covered by tests (one removal test per alias)
  • Dask chunk boundaries handled correctly (unchanged)
  • No premature materialization or unnecessary copies
  • Benchmark exists or is not needed
  • README feature matrix updated (no row changes needed)
  • Docstrings present and accurate (.. deprecated:: notes and the zones_ids entry removed)

@brendancol brendancol left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PR Review: follow-up after review fixes

Disposition of the first-pass findings:

  • Suggestion (accessor crop rename not documented): fixed in the PR body; the migration page row lives in #3761 and will be updated there before 1.0.0 is tagged.
  • Nit (stale zones_ids filter in test_crop_zone_ids_does_not_warn): fixed in 078a60c; the test now rejects any DeprecationWarning.

Nothing new on re-read. Diff since the first review is the one test line.

This branch has not been deployed

No deployments
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.

Remove deprecated hydro, zonal, focal and classify aliases for 1.0.0

1 participant