-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Add annotations for np.lib.ufunclike
#18377
Conversation
@@ -189,7 +189,8 @@ def isposinf(x, out=None): | |||
try: | |||
signbit = ~nx.signbit(x) | |||
except TypeError as e: | |||
raise TypeError('This operation is not supported for complex values ' | |||
dtype = nx.asanyarray(x).dtype | |||
raise TypeError(f'This operation is not supported for {dtype} values ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exception message would previously assume that that the dtype of the (invalid) array was complex. This is not necessarily true though, as the very same exception will also be triggered by timedelta64
and datetime64
arrays.
x: _ArrayLikeFloat_co, | ||
out: None = ..., | ||
) -> _ArrayOrScalar[floating[Any]]: ... | ||
@overload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be good to have 2 blank lines between functions (PEP8).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you are trying to group the functions, but I find it more difficult to read without the blank lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For overloads it's generally common practice to exclude the blank lines (example from typeshed).
Note that this area is not quite covered by PEP 8 though: the description of a single function with multiply signatures.
Just some style nits, otherwise LGTM. |
Thanks Bas. |
Per the title: this PR adds annotations for
np.lib.ufunclike
.DType support also turned out to be fairly straightforward to implement here, so that was definitely a plus.