| 1791 | */ |
| 1792 | |
| 1793 | NPY_NO_EXPORT PyObject * |
| 1794 | PyArray_CheckFromAny_int(PyObject *op, PyArray_Descr *in_descr, |
| 1795 | PyArray_DTypeMeta *in_DType, int min_depth, |
| 1796 | int max_depth, int requires, PyObject *context) |
| 1797 | { |
| 1798 | PyObject *obj; |
| 1799 | if (requires & NPY_ARRAY_NOTSWAPPED) { |
| 1800 | if (!in_descr && PyArray_Check(op) && |
| 1801 | PyArray_ISBYTESWAPPED((PyArrayObject* )op)) { |
| 1802 | in_descr = PyArray_DescrNew(PyArray_DESCR((PyArrayObject *)op)); |
| 1803 | if (in_descr == NULL) { |
| 1804 | return NULL; |
| 1805 | } |
| 1806 | } |
| 1807 | else if (in_descr && !PyArray_ISNBO(in_descr->byteorder)) { |
| 1808 | PyArray_DESCR_REPLACE(in_descr); |
| 1809 | } |
| 1810 | if (in_descr && in_descr->byteorder != NPY_IGNORE) { |
| 1811 | in_descr->byteorder = NPY_NATIVE; |
| 1812 | } |
| 1813 | } |
| 1814 | |
| 1815 | obj = PyArray_FromAny_int(op, in_descr, in_DType, min_depth, |
| 1816 | max_depth, requires, context); |
| 1817 | if (obj == NULL) { |
| 1818 | return NULL; |
| 1819 | } |
| 1820 | |
| 1821 | if ((requires & NPY_ARRAY_ELEMENTSTRIDES) |
| 1822 | && !PyArray_ElementStrides(obj)) { |
| 1823 | PyObject *ret; |
| 1824 | if (requires & NPY_ARRAY_ENSURENOCOPY) { |
| 1825 | PyErr_SetString(PyExc_ValueError, |
| 1826 | "Unable to avoid copy while creating a new array."); |
| 1827 | return NULL; |
| 1828 | } |
| 1829 | ret = PyArray_NewCopy((PyArrayObject *)obj, NPY_ANYORDER); |
| 1830 | Py_DECREF(obj); |
| 1831 | obj = ret; |
| 1832 | } |
| 1833 | return obj; |
| 1834 | } |
| 1835 | |
| 1836 | |
| 1837 | /*NUMPY_API |
no test coverage detected