| 1253 | |
| 1254 | #include <stdio.h> |
| 1255 | static PyObject * |
| 1256 | array_resize(PyArrayObject *self, PyObject *args, PyObject *kwds) |
| 1257 | { |
| 1258 | static char *kwlist[] = {"refcheck", NULL}; |
| 1259 | Py_ssize_t size = PyTuple_Size(args); |
| 1260 | int refcheck = 1; |
| 1261 | PyArray_Dims newshape; |
| 1262 | PyObject *ret, *obj; |
| 1263 | |
| 1264 | |
| 1265 | if (!NpyArg_ParseKeywords(kwds, "|i", kwlist, &refcheck)) { |
| 1266 | return NULL; |
| 1267 | } |
| 1268 | |
| 1269 | if (size == 0) { |
| 1270 | Py_RETURN_NONE; |
| 1271 | } |
| 1272 | else if (size == 1) { |
| 1273 | obj = PyTuple_GET_ITEM(args, 0); |
| 1274 | if (obj == Py_None) { |
| 1275 | Py_RETURN_NONE; |
| 1276 | } |
| 1277 | args = obj; |
| 1278 | } |
| 1279 | if (!PyArray_IntpConverter(args, &newshape)) { |
| 1280 | if (!PyErr_Occurred()) { |
| 1281 | PyErr_SetString(PyExc_TypeError, "invalid shape"); |
| 1282 | } |
| 1283 | return NULL; |
| 1284 | } |
| 1285 | |
| 1286 | ret = PyArray_Resize(self, &newshape, refcheck, NPY_ANYORDER); |
| 1287 | npy_free_cache_dim_obj(newshape); |
| 1288 | if (ret == NULL) { |
| 1289 | return NULL; |
| 1290 | } |
| 1291 | Py_DECREF(ret); |
| 1292 | Py_RETURN_NONE; |
| 1293 | } |
| 1294 | |
| 1295 | static PyObject * |
| 1296 | array_repeat(PyArrayObject *self, PyObject *args, PyObject *kwds) { |
nothing calls this directly
no test coverage detected