Skip to content
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

Merged
merged 4 commits into from
Feb 10, 2021
Merged

Conversation

BvB93
Copy link
Member

@BvB93 BvB93 commented Feb 9, 2021

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.

@@ -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 '
Copy link
Member Author

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
Copy link
Member

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).

Copy link
Member

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.

Copy link
Member Author

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.

@charris
Copy link
Member

charris commented Feb 9, 2021

Just some style nits, otherwise LGTM.

@charris charris merged commit f6a71fe into numpy:master Feb 10, 2021
@charris
Copy link
Member

charris commented Feb 10, 2021

Thanks Bas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants