type hint array functions #6035
Unanswered
raybellwaves
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Asking for xarray-contrib/xskillscore#317? |
Beta Was this translation helpful? Give feedback.
0 replies
-
@max-sixty as the self-designated typing expert any ideas? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Does any have any recommendation of type hinting generic array functions? https://numpy.org/devdocs/reference/typing.html#numpy.typing.ArrayLike looks interesting.
Say I have a function:
which I want to apply to an xarray object (
xr.DataArray
orxr.Dataset
) (my main type). However, for testing and other purposes I may want to use it on anumpy.ndarray
ordask.array
.With numpy typing I can write
file.py:
but when I run
mypy file.py
I get long error message (see below) of Unsupported ...np.version : 1.21.4
mypy.version : 0.910
mypy --install-types --non-interactive file.py
will get rid of the first three lines in the Traceback below.I apologize this isn't a strict xarray questions but curious how people type hint generic array functions.
Beta Was this translation helpful? Give feedback.
All reactions