| 965 | |
| 966 | |
| 967 | static PyObject * |
| 968 | array_wraparray(PyArrayObject *self, PyObject *args) |
| 969 | { |
| 970 | PyArrayObject *arr; |
| 971 | PyObject *obj; |
| 972 | |
| 973 | if (PyTuple_Size(args) < 1) { |
| 974 | PyErr_SetString(PyExc_TypeError, |
| 975 | "only accepts 1 argument"); |
| 976 | return NULL; |
| 977 | } |
| 978 | obj = PyTuple_GET_ITEM(args, 0); |
| 979 | if (obj == NULL) { |
| 980 | return NULL; |
| 981 | } |
| 982 | if (!PyArray_Check(obj)) { |
| 983 | PyErr_SetString(PyExc_TypeError, |
| 984 | "can only be called with ndarray object"); |
| 985 | return NULL; |
| 986 | } |
| 987 | arr = (PyArrayObject *)obj; |
| 988 | |
| 989 | if (Py_TYPE(self) != Py_TYPE(arr)) { |
| 990 | PyArray_Descr *dtype = PyArray_DESCR(arr); |
| 991 | Py_INCREF(dtype); |
| 992 | return PyArray_NewFromDescrAndBase( |
| 993 | Py_TYPE(self), |
| 994 | dtype, |
| 995 | PyArray_NDIM(arr), |
| 996 | PyArray_DIMS(arr), |
| 997 | PyArray_STRIDES(arr), PyArray_DATA(arr), |
| 998 | PyArray_FLAGS(arr), (PyObject *)self, obj); |
| 999 | } else { |
| 1000 | /*The type was set in __array_prepare__*/ |
| 1001 | Py_INCREF(arr); |
| 1002 | return (PyObject *)arr; |
| 1003 | } |
| 1004 | } |
| 1005 | |
| 1006 | |
| 1007 | static PyObject * |
nothing calls this directly
no test coverage detected