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
| 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) { |