NUMPY_API * Copy an array. */
| 473 | * Copy an array. |
| 474 | */ |
| 475 | NPY_NO_EXPORT PyObject * |
| 476 | PyArray_NewCopy(PyArrayObject *obj, NPY_ORDER order) |
| 477 | { |
| 478 | PyArrayObject *ret; |
| 479 | |
| 480 | if (obj == NULL) { |
| 481 | PyErr_SetString(PyExc_ValueError, |
| 482 | "obj is NULL in PyArray_NewCopy"); |
| 483 | return NULL; |
| 484 | } |
| 485 | |
| 486 | ret = (PyArrayObject *)PyArray_NewLikeArray(obj, order, NULL, 1); |
| 487 | if (ret == NULL) { |
| 488 | return NULL; |
| 489 | } |
| 490 | |
| 491 | if (PyArray_AssignArray(ret, obj, NULL, NPY_UNSAFE_CASTING) < 0) { |
| 492 | Py_DECREF(ret); |
| 493 | return NULL; |
| 494 | } |
| 495 | |
| 496 | return (PyObject *)ret; |
| 497 | } |
| 498 | |
| 499 | /*NUMPY_API |
| 500 | * View |
no test coverage detected