GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — TYP: ``hstack`` and ``vstack`` shape-typing by jorenham · Pull Request #32238 · numpy/numpy

Conversation

@jorenham

@jorenham jorenham commented Aug 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

As part of https://gist.github.com/jorenham/36c78602a7ca866ddb2a917de48ccdd0, this improves shape-typing for np.hstack and np.vstack.


This one was actually mostly written by AI! It came out pretty much exactly as I would have written it, so that's kinda awesome (and a bit scary).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jorenham jorenham added the 41 - Static typing label Aug 10, 2026
@jorenham jorenham added this to the 2.6.0 Release milestone Aug 10, 2026
@github-actions

This comment has been minimized.

Sign in to view
@jorenham

jorenham commented Aug 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

RE: the mypy_primer diff:

  • colour: this apparently resolves a bunch of false positives; good!
  • xarray: this new error (src) reports that a 1d array is being assigned to a 2d array. This can be avoided by changing the optuna mypy config to allow for redefinitions. It's not something we can do anything about, so all good.
  • optuna: a mypy bug (Crash on the numpy main branch: AssertionError in check_multi_assignment_from_tuple python/mypy#21824) that the mypy team was already kind enough to open a PR for after I reported this yesterday.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jorenham

This comment was marked as resolved.

Sign in to view
@jorenham
jorenham marked this pull request as draft August 10, 2026 12:34
@jorenham
TYP: hstack and vstack shape-typing
c42c4f3
@jorenham
jorenham force-pushed the typing/-stack/shape-typing branch from 29f5263 to c42c4f3 Compare August 10, 2026 12:48
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

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

xarray (https://github.com/pydata/xarray)
+ xarray/tests/test_plot.py:566: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, int], dtype[float64]]", variable has type "ndarray[tuple[int], dtype[float64]]")  [assignment]

colour (https://github.com/colour-science/colour)
- colour/plotting/section.py:247: error: List item 0 has incompatible type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | str | None"; expected "_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]"  [list-item]
- colour/plotting/section.py:247: error: List item 1 has incompatible type "float"; expected "_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]"  [list-item]
- colour/plotting/diagrams.py:599: error: List item 0 has incompatible type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | str | None"; expected "_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]"  [list-item]
- colour/plotting/diagrams.py:599: error: List item 1 has incompatible type "float"; expected "_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]"  [list-item]
- colour/plotting/diagrams.py:604: error: List item 0 has incompatible type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | str | None"; expected "_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]"  [list-item]
- colour/plotting/diagrams.py:604: error: List item 1 has incompatible type "float"; expected "_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]"  [list-item]

optuna (https://github.com/optuna/optuna)
  ./optuna/study/_multi_objective.py:182: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
jorenham reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jorenham
jorenham marked this pull request as ready for review August 10, 2026 14:17
@charris

charris commented Aug 10, 2026

Copy link
Copy Markdown
Member

Should we wait on mypy?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jorenham

jorenham commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

Should we wait on mypy?

Nah, it might be weeks or even months until the next mypy release, and the internal error only causes mypy_primer to not run on optuna, so it should be fine to ignore.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@charris
charris merged commit feed9a8 into numpy:main Aug 10, 2026
14 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@charris

charris commented Aug 10, 2026

Copy link
Copy Markdown
Member

Thanks Joren.

jorenham reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jorenham
jorenham deleted the typing/-stack/shape-typing branch August 10, 2026 23:30
This was referenced Aug 11, 2026
TYP: stack shape-typing #32248
Merged
TYP: np.column_stack shape-typing #32267
Merged
@jorenham jorenham mentioned this pull request Sep 30, 2026
TYP/DOC: release notes for the main numpy namespace shape-typing improvements #32835
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

41 - Static typing

Projects

None yet

Milestone

2.6.0 Release

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@jorenham @charris
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.