pybind11 icon indicating copy to clipboard operation
pybind11 copied to clipboard

[BUG]: Docstring Types for Numpy/Eigen Matricies

Open InvincibleRMC opened this issue 1 year ago • 0 comments

Required prerequisites

  • [X] Make sure you've read the documentation. Your issue may be addressed there.
  • [X] Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
  • [X] Consider asking first in the Gitter chat room or in a Discussion.

What version (or hash if on master) of pybind11 are you using?

51c2aa16de5b50fe4be6a0016d6090d4a831899e

Problem description

Hello there. The generated docstring for eigen tensors things look like the following numpy.ndarray[numpy.float64[3,2]]. I was curious why this was decided since this is not valid Python typing. It should be something like numpy.typing.NDArray[numpy.float64]. I assume the [3, 2] are supposed to be suggesting shape information but, that is still not supported https://github.com/numpy/numpy/issues/16544. The generated syntax causes stubgen to crash. I'm fine fixing it I just wanted more information on what exactly was going on here.

Reproducible example code

Running mypy stubgen on the test cases.

stubgen -p pybind11_tests.eigen_tensor

Is this a regression? Put the last known working version here if it is.

Not a regression

InvincibleRMC avatar Jun 29 '24 03:06 InvincibleRMC