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
| 1254 | /// If refcheck is true and more that one reference exist to this array |
| 1255 | /// then resize will succeed only if it makes a reshape, i.e. original size doesn't change |
| 1256 | void resize(ShapeContainer new_shape, bool refcheck = true) { |
| 1257 | detail::npy_api::PyArray_Dims d |
| 1258 | = {// Use reinterpret_cast for PyPy on Windows (remove if fixed, checked on 7.3.1) |
| 1259 | reinterpret_cast<Py_intptr_t *>(new_shape->data()), |
| 1260 | int(new_shape->size())}; |
| 1261 | // try to resize, set ordering param to -1 cause it's not used anyway |
| 1262 | auto new_array = reinterpret_steal<object>( |
| 1263 | detail::npy_api::get().PyArray_Resize_(m_ptr, &d, int(refcheck), -1)); |
| 1264 | if (!new_array) { |
| 1265 | throw error_already_set(); |
| 1266 | } |
| 1267 | if (isinstance<array>(new_array)) { |
| 1268 | *this = std::move(new_array); |
| 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | /// Optional `order` parameter omitted, to be added as needed. |
| 1273 | array reshape(ShapeContainer new_shape) { |
no test coverage detected