Skip to content

proximity: add return annotations to allocation and direction#2719

Open
brendancol wants to merge 1 commit into
mainfrom
deep-sweep-api-consistency-proximity-2026-05-29-01
Open

proximity: add return annotations to allocation and direction#2719
brendancol wants to merge 1 commit into
mainfrom
deep-sweep-api-consistency-proximity-2026-05-29-01

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #2717

allocation and direction now carry the same -> xr.DataArray return annotation that proximity already has. The three functions share a signature and return type, so their annotations should match.

  • Annotation only: no behavior, signature, or default changes. Not a breaking change.
  • Adds a parametrized test asserting the three siblings report the same return annotation via inspect.signature.

Backend coverage: unaffected (no runtime code changed). numpy / cupy / dask+numpy / dask+cupy paths are untouched.

Test plan:

  • pytest xrspatial/tests/test_proximity.py::test_return_annotation_consistency (3 passed)
  • proximity/allocation/direction default-behavior slice (17 passed)
  • flake8 on changed files (no new findings)

allocation and direction now match proximity's -> xr.DataArray return
annotation. Annotation only, no behavior change. Adds a parametrized
test asserting the three siblings share the same return annotation.
Copy link
Copy Markdown
Contributor Author

@brendancol brendancol left a comment

Choose a reason for hiding this comment

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

Domain-aware review (API-consistency sweep, proximity module).

Blockers: none.

Suggestions: none blocking. The annotation widens to match proximity's existing -> xr.DataArray, which is the right consistency target. Note that all three are wrapped by @supports_dataset and can return a Dataset, so a stricter xr.DataArray | xr.Dataset would be more precise. Matching the existing proximity annotation is the correct scope here; broadening all three is a separate call and out of scope for this PR.

Nits: none.

Verified:

  • inspect.signature reports xr.DataArray for all three functions (the @supports_dataset wrapper preserves the signature via functools.wraps), so the new test exercises the real public surface.
  • Annotation-only change; no runtime path touched. numpy / cupy / dask+numpy / dask+cupy behavior unchanged.
  • New test and the proximity/allocation/direction default-behavior slice pass; flake8 reports no new findings on the changed files.

@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.

proximity: add missing return annotations to allocation and direction

1 participant