Skip to content

TYP: apply_along_axis shape-typing and improved dtypes - #32676

Merged
charris merged 1 commit into
numpy:mainfrom
jorenham:typing/apply_along_axis/shape-typing
Sep 17, 2026
Merged

charris merged 1 commit into
numpy:mainfrom
jorenham:typing/apply_along_axis/shape-typing

Conversation

@jorenham

Copy link
Copy Markdown
Member

np.apply_along_axis now returns exact shape-types in the 0-2d cases based on the combination of func1d return type and the arr shape-type. Exact dtypes are now also returned when func1d returns python builtin scalars (bool/int/float/complex).


Pair programmed with AI.

@jorenham jorenham added this to the 2.6.0 Release milestone Sep 17, 2026
@charris
charris merged commit 87cde1b into numpy:main Sep 17, 2026
16 checks passed
@charris

charris commented Sep 17, 2026

Copy link
Copy Markdown
Member

Thanks Joren.

I have a question, it there a way to distinguish between returning a view vs a new array?

@jorenham

Copy link
Copy Markdown
Member Author

it there a way to distinguish between returning a view vs a new array?

There isn't; both the view and the original are nominal ndarray types, and there's no generic type parameter for that. Do you have a use case in mind or were you just curious?

@jorenham
jorenham deleted the typing/apply_along_axis/shape-typing branch September 17, 2026 14:27
@charris

charris commented Sep 17, 2026

Copy link
Copy Markdown
Member

Just curious, mainly because it affects data flow in a program. Overall, I'm wondering how much typing tells you about the structure of NumPy itself. If you handed over all the type files, what could an AI pull out of them.

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.

2 participants