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

Method resize

include/pybind11/numpy.h:1274–1288  ·  view source on GitHub ↗

Resize array to given shape If refcheck is true and more that one reference exist to this array then resize will succeed only if it makes a reshape, i.e. original size doesn't change

Source from the content-addressed store, hash-verified

1272 /// If refcheck is true and more that one reference exist to this array
1273 /// then resize will succeed only if it makes a reshape, i.e. original size doesn't change
1274 void resize(ShapeContainer new_shape, bool refcheck = true) {
1275 detail::npy_api::PyArray_Dims d
1276 = {// Use reinterpret_cast for PyPy on Windows (remove if fixed, checked on 7.3.1)
1277 reinterpret_cast<Py_intptr_t *>(new_shape->data()),
1278 int(new_shape->size())};
1279 // try to resize, set ordering param to -1 cause it's not used anyway
1280 auto new_array = reinterpret_steal<object>(
1281 detail::npy_api::get().PyArray_Resize_(m_ptr, &d, int(refcheck), -1));
1282 if (!new_array) {
1283 throw error_already_set();
1284 }
1285 if (isinstance<array>(new_array)) {
1286 *this = std::move(new_array);
1287 }
1288 }
1289
1290 /// Optional `order` parameter omitted, to be added as needed.
1291 array reshape(ShapeContainer new_shape) {

Callers 3

TEST_SUBMODULEFunction · 0.80
broadcastFunction · 0.80
convert_elementsMethod · 0.80

Calls 4

getFunction · 0.85
moveFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by 1

TEST_SUBMODULEFunction · 0.64