-
-
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.twodim_base
#19261
Conversation
def tril_indices( | ||
n: int, | ||
k: int = ..., | ||
m: None | int = ..., | ||
) -> Tuple[NDArray[int_], NDArray[int_]]: ... |
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.
We currently have four functions here that return indices-arrays of the np.int_
dtype, rather than np.intp
.
Would this be worthwhile to change?
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.
Certainly worth discussing, I doubt it would cause problems. I'd like to get rid of C long
, it is too variable.
# NOTE: we're assuming/demanding here the `mask_func` returns | ||
# an ndarray of shape `(n, n)`; otherwise there is the possibility | ||
# of the output tuple having more or less than 2 elements | ||
@overload | ||
def mask_indices( | ||
n: int, | ||
mask_func: _MaskFunc[int], | ||
k: int = ..., | ||
) -> Tuple[NDArray[intp], NDArray[intp]]: ... |
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.
_MaskFunc
is currently expected to return a 2D array (shape (n, n)
).
I'd say this is a reasonable demand, even though it is a bit stricter than is truly necessary.
Thanks Bas. |
This PR adds annotations for the 15 functions in
np.lib.twodim_base
, including some basic dtype support.