captain_error
captain_error

Reputation: 11

How can I convert a nb::handle (or nb::object or PyObject*) into a nb::ndarray?

Nanobind has a function nb::ndarray_check(handle h) which returns true in case h is usable as an ndarray (e.g. if it implements the buffer protocol).

How do I actually create an instance of nb::ndarray from h?

nb::ndarray has a constructor explicit ndarray(detail::ndarray_handle *handle). But there seems to be none which takes a simple PyObject*, nb::handle, or nb::object as an argument.

Upvotes: 1

Views: 180

Answers (0)

Related Questions