templates: add type hints to from_template / list_templates#3543
Merged
Conversation
Annotate the two public template entry points to match the rest of the public API (generate_terrain, slope, aspect, etc.). Non-breaking; adds a test asserting both functions carry parameter and return annotations. Also records the api-consistency sweep result for the templates module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3542.
Adds type annotations to the two public functions in
xrspatial/templates.py:Both functions previously had no hints, while the analogous DataArray constructor
generate_terrainand most public entry points (slope, aspect, curvature, proximity, zonal, classify) are annotated. This brings the templates surface in line.Non-breaking: signatures and runtime behavior are unchanged. Verified
from_templateacross all four backends (numpy, dask+numpy, cupy, dask+cupy) on a CUDA host.Adds
test_public_functions_have_type_hints, which asserts both functions carry a return annotation and a hint on every parameter. Fulltest_templates.pypasses (64 tested).The
resolutionparameter intentionally maps toattrs['res']; that naming is left as is (resis the array-contract attr name,resolutionis the clearer constructor parameter).Found by the api-consistency sweep (category 3).