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

Method view

include/pybind11/numpy.h:1307–1315  ·  view source on GitHub ↗

Create a view of an array in a different data type. This function may fundamentally reinterpret the data in the array. It is the responsibility of the caller to ensure that this is safe. Only supports the `dtype` argument, the `type` argument is omitted, to be added as needed.

Source from the content-addressed store, hash-verified

1305 /// Only supports the `dtype` argument, the `type` argument is omitted,
1306 /// to be added as needed.
1307 array view(const std::string &dtype) {
1308 auto &api = detail::npy_api::get();
1309 auto new_view = reinterpret_steal<array>(api.PyArray_View_(
1310 m_ptr, dtype::from_args(pybind11::str(dtype)).release().ptr(), nullptr));
1311 if (!new_view) {
1312 throw error_already_set();
1313 }
1314 return new_view;
1315 }
1316
1317 /// Ensure that the argument is a NumPy array
1318 /// In case of an error, nullptr is returned and the Python error is cleared.

Callers 5

test_array_attributesFunction · 0.45
test_shape_strides_spanFunction · 0.45
TEST_SUBMODULEFunction · 0.45
memoryviewMethod · 0.45

Calls 4

getFunction · 0.85
strClass · 0.85
ptrMethod · 0.80
releaseMethod · 0.80

Tested by 4

test_array_attributesFunction · 0.36
test_shape_strides_spanFunction · 0.36
TEST_SUBMODULEFunction · 0.36