| 1041 | |
| 1042 | |
| 1043 | static PyObject * |
| 1044 | array_getarray(PyArrayObject *self, PyObject *args) |
| 1045 | { |
| 1046 | PyArray_Descr *newtype = NULL; |
| 1047 | PyObject *ret; |
| 1048 | |
| 1049 | if (!PyArg_ParseTuple(args, "|O&:__array__", |
| 1050 | PyArray_DescrConverter, &newtype)) { |
| 1051 | Py_XDECREF(newtype); |
| 1052 | return NULL; |
| 1053 | } |
| 1054 | |
| 1055 | /* convert to PyArray_Type */ |
| 1056 | if (!PyArray_CheckExact(self)) { |
| 1057 | PyArrayObject *new; |
| 1058 | |
| 1059 | Py_INCREF(PyArray_DESCR(self)); |
| 1060 | new = (PyArrayObject *)PyArray_NewFromDescrAndBase( |
| 1061 | &PyArray_Type, |
| 1062 | PyArray_DESCR(self), |
| 1063 | PyArray_NDIM(self), |
| 1064 | PyArray_DIMS(self), |
| 1065 | PyArray_STRIDES(self), |
| 1066 | PyArray_DATA(self), |
| 1067 | PyArray_FLAGS(self), |
| 1068 | NULL, |
| 1069 | (PyObject *)self |
| 1070 | ); |
| 1071 | if (new == NULL) { |
| 1072 | return NULL; |
| 1073 | } |
| 1074 | self = new; |
| 1075 | } |
| 1076 | else { |
| 1077 | Py_INCREF(self); |
| 1078 | } |
| 1079 | |
| 1080 | if ((newtype == NULL) || PyArray_EquivTypes(PyArray_DESCR(self), newtype)) { |
| 1081 | return (PyObject *)self; |
| 1082 | } |
| 1083 | else { |
| 1084 | ret = PyArray_CastToType(self, newtype, 0); |
| 1085 | Py_DECREF(self); |
| 1086 | return ret; |
| 1087 | } |
| 1088 | } |
| 1089 | |
| 1090 | /* |
| 1091 | * Check whether any of the input and output args have a non-default |
nothing calls this directly
no test coverage detected