Skip to content

resample: add type annotations to public signature (#2544)#2546

Merged
brendancol merged 1 commit into
mainfrom
deep-sweep-api-consistency-resample-2026-05-27
May 28, 2026
Merged

resample: add type annotations to public signature (#2544)#2546
brendancol merged 1 commit into
mainfrom
deep-sweep-api-consistency-resample-2026-05-27

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #2544.

Summary

Annotations use from __future__ import annotations (already at top of the file) for the | union syntax. typing.get_type_hints(resample) resolves all 7 names without error.

Findings NOT fixed in this PR

Documented in the sweep state CSV; left for separate design issues:

  • Cross-module rename method (resample) vs resampling (reproject/merge) — same conceptual parameter, different name. Cross-cutting rename that needs a deprecation shim on either side.
  • Cross-cutting first-arg name agg vs raster across the wider library — library-wide drift, not per-module.

Test plan

  • All 169 existing xrspatial/tests/test_resample.py tests pass.
  • New test_resample_signature_annot_2544.py (3 tests) passes.
  • typing.get_type_hints(resample) resolves all annotations at runtime.
  • cupy backend smoke-tested with nearest, bilinear, and average methods on host with CUDA_AVAILABLE=True.

API consistency sweep finding (Cat 3 MEDIUM). resample() was the only
public symbol in xrspatial.resample without type annotations on any
parameter or return type. Sibling terrain modules (slope, aspect,
hillshade, curvature) all annotate `agg: xr.DataArray` and declare
`-> xr.DataArray`; the docstring already declared the intended types,
so this was a doc-vs-signature drift.

- Annotate agg, scale_factor, target_resolution, method, nodata, name
  and the return type using `from __future__ import annotations` for
  the `|` union syntax already in use.
- Note in the docstring that `agg` accepts xr.Dataset via the
  @supports_dataset decorator.
- Add test_resample_signature_annot_2544.py pinning every param and
  the return type so future contributors cannot silently drop them.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 28, 2026
@brendancol brendancol merged commit 3823149 into main May 28, 2026
9 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.

resample: add type annotations to public signature

1 participant