Skip to content

BUG, TYP: _core.multiarray.* function runtime signatures - #30143

Merged
charris merged 4 commits into
numpy:mainfrom
jorenham:_core.multiarray-signatures
Nov 4, 2025
Merged

charris merged 4 commits into
numpy:mainfrom
jorenham:_core.multiarray-signatures

Conversation

@jorenham

@jorenham jorenham commented Nov 4, 2025 •

Copy link
Copy Markdown
Member

This is yet another batch of inspect.signature fixes, similar to #30104, #30114, #30121, #30124, #30126, #30137, #30138, and #30140. The following functions are affected:

  • numpy.empty_like
  • numpy.concatenate
  • numpy.inner
  • numpy.where
  • numpy.lexsort
  • numpy.can_cast
  • numpy.min_scalar_type
  • numpy.result_type
  • numpy.dot
  • numpy.vdot
  • numpy.bincount
  • numpy.ravel_multi_index
  • numpy.unravel_index
  • numpy.copyto,
  • numpy.putmask
  • numpy.packbits
  • numpy.unpackbits
  • numpy.shares_memory
  • numpy.may_share_memory
  • numpy.is_busday
  • numpy.busday_offset
  • numpy.busday_count
  • numpy.datetime_as_string

@jorenham jorenham changed the title _core.multiarray-signatures BUG, TYP: _core.multiarray.* function runtime signatures Nov 4, 2025
@jorenham jorenham added this to the 2.4.0 release milestone Nov 4, 2025
@github-actions

This comment has been minimized.

@jorenham

jorenham commented Nov 4, 2025 •

Copy link
Copy Markdown
Member Author

The new pandas stubtest error are caused by appending an array to a list of ints. That array is the result of np.where, which mypy apparently inferred as Any before this change.
Mypy now being better able to understand np.where also explains the resolved colour errors.

@charris

charris commented Nov 4, 2025

Copy link
Copy Markdown
Member

Needs rebase.

@jorenham
jorenham force-pushed the _core.multiarray-signatures branch from 5cb6d0c to 91b4a3d Compare November 4, 2025 16:44
@github-actions

github-actions Bot commented Nov 4, 2025

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:

pandas (https://github.com/pandas-dev/pandas)
+ pandas/plotting/_matplotlib/core.py:1998: error: List item 0 has incompatible type "ndarray[tuple[Any, ...], dtype[float64]]"; expected "int"  [list-item]
+ pandas/plotting/_matplotlib/core.py:1998: error: List item 1 has incompatible type "ndarray[tuple[Any, ...], dtype[float64]]"; expected "int"  [list-item]

colour (https://github.com/colour-science/colour)
- colour/plotting/quality.py:186: error: No overload variant of "where" matches argument types "ndarray[tuple[Any, ...], dtype[numpy.bool[builtins.bool]]]", "Any", "None"  [call-overload]
- colour/plotting/quality.py:186: note: Possible overload variants:
- colour/plotting/quality.py:186: note:     def where(Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], /) -> tuple[ndarray[tuple[Any, ...], dtype[signedinteger[_32Bit | _64Bit]]], ...]
- colour/plotting/quality.py:186: note:     def where(Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], /) -> ndarray[tuple[Any, ...], dtype[Any]]

@charris
charris merged commit e8687a3 into numpy:main Nov 4, 2025
2 checks passed
@charris

charris commented Nov 4, 2025

Copy link
Copy Markdown
Member

Thanks Joren.

@jorenham
jorenham deleted the _core.multiarray-signatures branch November 4, 2025 17:51
charris pushed a commit that referenced this pull request Nov 6, 2025
This fixes `inspect.signature` for

- `np.random.BitGenerator`
- `np.random.Generator`
- `np.random.MT19937`
- `np.random.PCG64`
- `np.random.PCG64DXSM`
- `np.random.Philox`
- `np.random.RandomState`
- `np.random.SFC64`
- `np.random.SeedSequence`
- `np.random.bit_generator.SeedlessSeedSequence`

This also fixes a typo in `bit_generator.pxd` that accidentally defined an empty unused class `np.random.bit_generator.SeedlessSequence`.

Related to #30104, #30114, #30121, #30124, #30126, #30137, #30138, #30140, #30143, #30146, #30147, and #30155
cakedev0 pushed a commit to cakedev0/numpy that referenced this pull request Dec 5, 2025
This fixes `inspect.signature` for

- `np.random.BitGenerator`
- `np.random.Generator`
- `np.random.MT19937`
- `np.random.PCG64`
- `np.random.PCG64DXSM`
- `np.random.Philox`
- `np.random.RandomState`
- `np.random.SFC64`
- `np.random.SeedSequence`
- `np.random.bit_generator.SeedlessSeedSequence`

This also fixes a typo in `bit_generator.pxd` that accidentally defined an empty unused class `np.random.bit_generator.SeedlessSequence`.

Related to numpy#30104, numpy#30114, numpy#30121, numpy#30124, numpy#30126, numpy#30137, numpy#30138, numpy#30140, numpy#30143, numpy#30146, numpy#30147, and numpy#30155
IndifferentArea pushed a commit to IndifferentArea/numpy that referenced this pull request Dec 7, 2025
This fixes `inspect.signature` for

- `np.random.BitGenerator`
- `np.random.Generator`
- `np.random.MT19937`
- `np.random.PCG64`
- `np.random.PCG64DXSM`
- `np.random.Philox`
- `np.random.RandomState`
- `np.random.SFC64`
- `np.random.SeedSequence`
- `np.random.bit_generator.SeedlessSeedSequence`

This also fixes a typo in `bit_generator.pxd` that accidentally defined an empty unused class `np.random.bit_generator.SeedlessSequence`.

Related to numpy#30104, numpy#30114, numpy#30121, numpy#30124, numpy#30126, numpy#30137, numpy#30138, numpy#30140, numpy#30143, numpy#30146, numpy#30147, and numpy#30155
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