Conversation
Add overloads that match the __array_ufunc__ protocols of NumPy's ufunc stubs (numpy/_core/umath.pyi), so that type checkers can infer the result of e.g. np.exp(da) or np.add(da, ds). Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
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.
Description
Adds type hints to
__array_ufunc__ofVariable,DataArrayandDataset, matching the__array_ufunc__protocols of NumPy's new ufunc stubs (numpy/_core/umath.pyi, NumPy 2.6).Self, binary ufuncs the higher priority type (Dataset > DataArray > Variable), unsupported methods (reduce,at, ...)NoReturn.np.exp(da)this only takes effect once NumPy prefers these protocols over itsArrayLikeoverloads (TYP: Improved support for typing with __array_function__ usage numpy/numpy#25024, ENH: Static typing support for custom array containers numpy/numpy#21737).Checklist
__array_ufunc__does not work with typing #6524, Type annotation compatibility with numpy ufuncs #8388whats-new.rstAI Disclosure
Tools: Claude Code
[This is Claude Code on behalf of Michael Niklas]
🤖 Generated with Claude Code