| 1840 | } |
| 1841 | |
| 1842 | static PyObject * |
| 1843 | array_asarray(PyObject *NPY_UNUSED(ignored), |
| 1844 | PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) |
| 1845 | { |
| 1846 | PyObject *op; |
| 1847 | npy_dtype_info dt_info = {NULL, NULL}; |
| 1848 | NPY_ORDER order = NPY_KEEPORDER; |
| 1849 | PyObject *like = Py_None; |
| 1850 | NPY_PREPARE_ARGPARSER; |
| 1851 | |
| 1852 | if (len_args != 1 || (kwnames != NULL)) { |
| 1853 | if (npy_parse_arguments("asarray", args, len_args, kwnames, |
| 1854 | "a", NULL, &op, |
| 1855 | "|dtype", &PyArray_DTypeOrDescrConverterOptional, &dt_info, |
| 1856 | "|order", &PyArray_OrderConverter, &order, |
| 1857 | "$like", NULL, &like, |
| 1858 | NULL, NULL, NULL) < 0) { |
| 1859 | Py_XDECREF(dt_info.descr); |
| 1860 | Py_XDECREF(dt_info.dtype); |
| 1861 | return NULL; |
| 1862 | } |
| 1863 | if (like != Py_None) { |
| 1864 | PyObject *deferred = array_implement_c_array_function_creation( |
| 1865 | "asarray", like, NULL, NULL, args, len_args, kwnames); |
| 1866 | if (deferred != Py_NotImplemented) { |
| 1867 | Py_XDECREF(dt_info.descr); |
| 1868 | Py_XDECREF(dt_info.dtype); |
| 1869 | return deferred; |
| 1870 | } |
| 1871 | } |
| 1872 | } |
| 1873 | else { |
| 1874 | op = args[0]; |
| 1875 | } |
| 1876 | |
| 1877 | PyObject *res = _array_fromobject_generic( |
| 1878 | op, dt_info.descr, dt_info.dtype, NPY_FALSE, order, NPY_FALSE, 0); |
| 1879 | Py_XDECREF(dt_info.descr); |
| 1880 | Py_XDECREF(dt_info.dtype); |
| 1881 | return res; |
| 1882 | } |
| 1883 | |
| 1884 | static PyObject * |
| 1885 | array_asanyarray(PyObject *NPY_UNUSED(ignored), |
nothing calls this directly
no test coverage detected