Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jorenham
Copy link
Member

Added overloads to the (direct) array constructor functions in the stubs. These "bind" the type of the passed shape argument to the shape-type parameter of the numpy.ndarray. Note that this is only possible when the shape is passed as shape: int or shape: tuple[int, int], since e.g. the list type contains no information about its length (i.e. the number of dimensions).

This affects the type-signatures of:

  • numpy.empty (numpy._core.multiarray.empty)
  • numpy.zeros (numpy._core.multiarray.zeros)
  • numpy.ones (numpy._core.numeric.ones)
  • numpy.full (numpy._core.numeric.full)

implementation notes:


This should be backwards-compatible, because the ndarray shape-type parameter is covariant, see #26081.

@charris
Copy link
Member

charris commented Aug 30, 2024

Needs rebase.

@jorenham jorenham force-pushed the typing/shaped-array-constructors branch from 9211e27 to 7f85de4 Compare September 2, 2024 10:44
@charris
Copy link
Member

charris commented Sep 2, 2024

Needs another rebase :)

@jorenham jorenham force-pushed the typing/shaped-array-constructors branch from 7f85de4 to f3dd2e1 Compare September 2, 2024 14:09
@charris charris merged commit f1d11b3 into numpy:main Sep 2, 2024
@charris
Copy link
Member

charris commented Sep 2, 2024

Thanks @jorenham .

@jorenham jorenham deleted the typing/shaped-array-constructors branch September 2, 2024 15:39
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