8000 MAINT: simplifying annotations for np.core.from_numeric by BvB93 · Pull Request #16556 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: simplifying annotations for np.core.from_numeric #16556

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

Merged
merged 5 commits into from
Jun 10, 2020

Conversation

BvB93
Copy link
Member
@BvB93 BvB93 commented Jun 9, 2020

In one of the last pull requests over at numpy-stubs (numpy/numpy-stubs#71) we had a discussion about the complexity of the pull requests' respective annotations, more specifically about the ones trying to express >0D array-like objects (vectors, matrices, etc.).

As the complexity of the annotations came at the detriment of their readability, we arrived at the conclusion that it would be best to simplify them in a future pull request.

This pull request thus addresses aforementioned issue:

  • Annotations attempting to express >0D array-like objects have been simplified; they now are now assigned ArrayLike.

See Also

Copy link
Member
@person142 person142 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo test failures.

@BvB93 BvB93 marked this pull request as ready for review June 10, 2020 11:12
@BvB93
Copy link
Member Author
BvB93 commented Jun 10, 2020

The tests have been fixed as of 0f7f6a9.

If there are no further comments then the pull request can be merged, as far as I'm concerned.

@person142 person142 merged commit c0c7c42 into numpy:master Jun 10, 2020
@person142
Copy link
Member

Thanks @BvB93!

) -> Union[integer, bool_]: ...
@overload
def choose(
a: _ArrayLikeIntOrBool,
choices: Union[Sequence[ArrayLike], ndarray],
choices: ArrayLike,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
choices: ArrayLike,
choices: Sequence[ArrayLike],

I think it's important to emphasize that this input is not an array, as it means shapes like (0, 3) are not handled sensibly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the other overload

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 tricky part is that, without proper shape support, expressing this will be either very difficult and/or verbose.
For example even Sequence[ArrayLike] does not include the likes of np.ndarray or pd.DataFrane, both of which are (strictly speaking) not proper sequences.

@BvB93 BvB93 deleted the fromnumeric-cleaning branch June 12, 2020 11:02
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.

3 participants
0