Skip to content

zonal.crop uses zones_ids; siblings stats/crosstab use zone_ids #2521

@brendancol

Description

@brendancol

Summary

xrspatial.zonal.crop() accepts the parameter zones_ids (with the extra s),
while every other zonal function uses zone_ids for the same concept:

  • zonal.stats(..., zone_ids=...)
  • zonal.crosstab(..., zone_ids=...)
  • zonal.crop(zones, values, zones_ids=...) <-- inconsistent

Users who learn the convention from stats/crosstab will get a
TypeError when calling crop, and vice versa.

API Consistency Sweep Context

Found by the api-consistency sweep against the zonal module
(2026-05-27). Severity: HIGH (Cat 1 — parameter naming drift, both names
exist concurrently in the public API).

Proposed Fix (Deprecation Shim)

Since this is a breaking rename, the fix should:

  1. Accept both zone_ids (new, canonical) and zones_ids (legacy).
  2. Emit a DeprecationWarning when zones_ids is used.
  3. Raise if both are supplied.
  4. Update the docstring and the in-tree examples/tests to use zone_ids.
  5. Keep zones_ids working for at least one release cycle.

Test Plan

  • Existing test_crop() keeps passing (uses zones_ids, will emit
    DeprecationWarning but still work).
  • New test: calling crop(..., zone_ids=...) works identically.
  • New test: passing both raises TypeError.
  • New test: zones_ids triggers DeprecationWarning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions