MCPcopy Create free account
hub / github.com/pybind/pybind11 / ensure

Function ensure

include/pybind11/numpy.h:1495–1501  ·  view source on GitHub ↗

Ensure that the argument is a NumPy array of the correct dtype (and if not, try to convert it). In case of an error, nullptr is returned and the Python error is cleared.

Source from the content-addressed store, hash-verified

1493 /// Ensure that the argument is a NumPy array of the correct dtype (and if not, try to convert
1494 /// it). In case of an error, nullptr is returned and the Python error is cleared.
1495 static array_t ensure(handle h) {
1496 auto result = reinterpret_steal<array_t>(raw_array_t(h.ptr()));
1497 if (!result) {
1498 PyErr_Clear();
1499 }
1500 return result;
1501 }
1502
1503 static bool check_(handle h) {
1504 const auto &api = detail::npy_api::get();

Callers 4

loadMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85
loadFunction · 0.85

Calls 1

ptrMethod · 0.80

Tested by

no test coverage detected