Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TYP: Type MaskedArray.repeat, improve overloads for NDArray.repeat, generic.repeat, and np.repeat #28849

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 4 commits into from
Apr 29, 2025

Conversation

MarcoGorelli
Copy link
Member

No description provided.

@MarcoGorelli MarcoGorelli marked this pull request as ready for review April 28, 2025 15:40
@jorenham jorenham added the component: numpy.ma masked arrays label Apr 28, 2025
@jorenham jorenham self-requested a review April 28, 2025 16:38
numpy/ma/core.pyi Outdated Show resolved Hide resolved
numpy/ma/core.pyi Outdated Show resolved Hide resolved
@MarcoGorelli MarcoGorelli marked this pull request as draft April 28, 2025 20:02
@MarcoGorelli MarcoGorelli changed the title TYP: Type np.ma.repeat and MaskedArray.repeat TYP: Type np.ma.repeat, improve overloads for NDArray.repeat, generic.repeat, and np.repeat Apr 29, 2025
@MarcoGorelli MarcoGorelli marked this pull request as ready for review April 29, 2025 10:00
Copy link

Diff from mypy_primer, showing the effect of this PR on type check results on a corpus of open source code:

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/reshape/concat.py:936: error: Generator has incompatible item type "ndarray[tuple[int, ...], dtype[Any]]"; expected "ndarray[tuple[int], dtype[Any]]"  [misc]
+ pandas/core/reshape/concat.py:940: error: Argument 1 to "append" of "list" has incompatible type "ndarray[tuple[int, ...], dtype[Any]]"; expected "ndarray[tuple[int], dtype[Any]]"  [arg-type]

@MarcoGorelli MarcoGorelli changed the title TYP: Type np.ma.repeat, improve overloads for NDArray.repeat, generic.repeat, and np.repeat TYP: Type MaskedArray.repeat, improve overloads for NDArray.repeat, generic.repeat, and np.repeat Apr 29, 2025
@jorenham
Copy link
Member

Diff from mypy_primer, showing the effect of this PR on type check results on a corpus of open source code:

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/reshape/concat.py:936: error: Generator has incompatible item type "ndarray[tuple[int, ...], dtype[Any]]"; expected "ndarray[tuple[int], dtype[Any]]"  [misc]
+ pandas/core/reshape/concat.py:940: error: Argument 1 to "append" of "list" has incompatible type "ndarray[tuple[int, ...], dtype[Any]]"; expected "ndarray[tuple[int], dtype[Any]]"  [arg-type]

relevant pandas code:
https://github.com/pandas-dev/pandas/blob/cf6de581e1c27f06107b5be9e7f2923d7bbc98a6/pandas/core/reshape/concat.py#L918-L940

@jorenham
Copy link
Member

The change to np.repeat will apparently cause new typing errors in pandas.

@mroeschke since you worked on pandas-dev/pandas#61265, perhaps you are willing to share your thoughts on this change?

@mroeschke
Copy link
Contributor

I'm fine to adapt to these typing changes in pandas (mostly by adding ignores or simple annotations until someone from the pandas community would like to improve the annotations internally)

@jorenham
Copy link
Member

I'm fine to adapt to these typing changes in pandas (mostly by adding ignores or simple annotations until someone from the pandas community would like to improve the annotations internally)

Good to hear, thanks!

@jorenham jorenham merged commit 9af251c into numpy:main Apr 29, 2025
75 checks passed
@jorenham
Copy link
Member

Thanks Marco

MaanasArora pushed a commit to MaanasArora/numpy that referenced this pull request May 8, 2025
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.