Skip to content

Navigation Menu

Sign in
Appearance settings

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: Fix inconsistent NDArray[float64].__[r]truediv__ return type with float #28702

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 1 commit into from
Apr 14, 2025

Conversation

jorenham
Copy link
Member

closes #28701

@jorenham jorenham added 09 - Backport-Candidate PRs tagged should be backported 41 - Static typing labels Apr 14, 2025
@jorenham
Copy link
Member Author

CI failure seems unrelated

Copy link

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

hydpy (https://github.com/hydpy-dev/hydpy)
- hydpy/core/testtools.py:1492: error: Incompatible return value type (got "ndarray[tuple[int, ...], dtype[floating[Any]]]", expected "ndarray[tuple[int, ...], dtype[float64]]")  [return-value]
- hydpy/core/parametertools.py:1540: error: Incompatible return value type (got "ndarray[tuple[int, ...], dtype[floating[Any]]]", expected "ndarray[tuple[int, ...], dtype[float64]]")  [return-value]
- hydpy/core/parametertools.py:1540: error: Incompatible return value type (got "float | ndarray[tuple[int, ...], dtype[floating[Any]]]", expected "float | ndarray[tuple[int, ...], dtype[float64]]")  [return-value]
- hydpy/core/parametertools.py:1567: error: Incompatible return value type (got "ndarray[tuple[int, ...], dtype[floating[Any]]]", expected "ndarray[tuple[int, ...], dtype[float64]]")  [return-value]
- hydpy/core/parametertools.py:1567: error: Incompatible return value type (got "float | ndarray[tuple[int, ...], dtype[floating[Any]]]", expected "float | ndarray[tuple[int, ...], dtype[float64]]")  [return-value]
- hydpy/auxs/armatools.py:722: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[floating[Any]]]", variable has type "Sequence[float] | ndarray[tuple[int, ...], dtype[float64]]")  [assignment]

@charris charris merged commit 5147e4d into numpy:main Apr 14, 2025
74 of 75 checks passed
@charris
Copy link
Member

charris commented Apr 14, 2025

Thanks Joren.

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Apr 14, 2025
@jorenham jorenham deleted the typing/fix-28701 branch April 14, 2025 16:31
@s-banach
Copy link

Sorry to bother you guys.
Will type annotations eventually be able to say things like
"my_array / 2.0 has the same n_dimensions as my_array"?

@jorenham
Copy link
Member Author

Sorry to bother you guys. Will type annotations eventually be able to say things like "my_array / 2.0 has the same n_dimensions as my_array"?

yes; that's the plan :)

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.

TYP: Loosing np.float64 in numpy array type after division with a Python float
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.