Document actual return types of vertical datum functions (#3097)#3134
Open
brendancol wants to merge 3 commits into
Open
Document actual return types of vertical datum functions (#3097)#3134brendancol wants to merge 3 commits into
brendancol wants to merge 3 commits into
Conversation
brendancol
commented
Jun 9, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
PR Review: Document actual return types of vertical datum functions (#3097)
Blockers
None.
Suggestions
None.
Nits
- The same three-line np.asarray explanation is repeated in four Returns sections (_vertical.py). Numpy-style docs favour explicit over DRY, so this is fine as-is; flagging only in case a shared "Notes" section is preferred later.
What looks good
- Each documented claim matches the code:
geoid_heightdoesfloat(out[0])on the scalar path andout.reshape(np.shape(lon))otherwise, and the wrappers returnnp.asarray(height) +/- N, so the new wording ("numpy scalar for scalar input, plain ndarray otherwise, DataArray coords not carried through") is verifiably accurate. TestVerticalReturnTypespins the types withtype(...) ischecks rather thanisinstance, so a silent change from float to np.float64 (or ndarray to DataArray) fails loudly and forces a doc update.- No runtime behaviour touched; the diff is Returns sections plus tests.
Checklist
- Docstrings present and accurate (verified against the implementation)
- Edge cases: scalar, 1-D array, and DataArray inputs all covered by the pin tests
- No behaviour change, so backend parity and NaN handling are unaffected
- Benchmark not applicable
- README feature matrix not applicable
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 #3097
The five vertical functions in
xrspatial/reproject/_vertical.pydescribed their return value as "same type as input", which is wrong: DataArray input returns a plain ndarray, and the four conversion wrappers return numpy scalars for scalar input (onlygeoid_heightconverts back to Python float).geoid_heightgives a Python float for scalar input, otherwise an ndarray shaped like the inputs; the wrappers passheight/depththroughnp.asarray, so scalar in gives a numpy scalar, array-like or DataArray in gives an ndarray.TestVerticalReturnTypespins those types so a future behaviour change has to update the docs too.Docs-only change at runtime; no behaviour modified. Making these functions round-trip DataArrays would be a separate feature decision, noted in the issue.
Test plan: