feat(types) Numpy.typing.NDArray (#5212)

* tests passing

* lint

* add comment

* remove empty tuple[()]

* test io_name

* style: pre-commit fixes

* remove accidental >

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* try T

* make both const_name

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* try and treat as string

* style: pre-commit fixes

* Update Numpy type hints

* style: pre-commit fixes

* re-run ci

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* re-run ci

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* remove escape characters

* Added tests for ArrayLike in signatures and fixed wrong types for Refs

---------

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tim Ohliger <ohliger.tim@gmail.com>
This commit is contained in:
Michael Carlstrom
2025-02-18 02:13:05 -05:00
committed by GitHub
parent 34a118fd36
commit 241524223a
10 changed files with 142 additions and 61 deletions

View File

@@ -586,4 +586,13 @@ TEST_SUBMODULE(numpy_array, sm) {
sm.def("return_array_pyobject_ptr_from_list", return_array_from_list<PyObject *>);
sm.def("return_array_handle_from_list", return_array_from_list<py::handle>);
sm.def("return_array_object_from_list", return_array_from_list<py::object>);
sm.def(
"round_trip_array_t",
[](const py::array_t<float> &x) -> py::array_t<float> { return x; },
py::arg("x"));
sm.def(
"round_trip_array_t_noconvert",
[](const py::array_t<float> &x) -> py::array_t<float> { return x; },
py::arg("x").noconvert());
}